Posts Tagged ‘php’

Posts Tagged ‘php’

PHP PECL Solr 2.1.0 Released

1.17.2015 | 6 Comments

I’m pleased to announce that The Official PHP Solr Extension 2.1.0 is out with exciting features.


The Solr extension allows you to communicate effectively with The Apache Solr Server in PHP.

The Solr extension is an extremely fast, light-weight, feature-rich library that allows PHP developers to communicate effectively with Solr Server instances.

There are built-in tools to add documents and make updates to The Solr Server.

Read more…

CakePHP Locale and Routing

7.31.2012 | 2 Comments


When I was working on the cakephp localization ( l10n ) and internationalization ( i18n ), I came across a problem so I decided to let the world know about it if anyone had got the same issue.

What we want here is that a user can go to the localized version of the website according to the URL identified, for instance we want the website to load the English locale when we pass a URL like this http://example.tld/eng/Controller/Action

The problem is that while implementing the routes for the language detection, the plugins made a conflict with the rules in the routes file. Language routing is easy but sometimes can be tricky.
Read more…

PHP Variable Variables and Variable Constants

6.17.2012 | 1 Comment

In this small article I’ll illustrate PHP’s variable variables and Variable constants. There is no variable constants in PHP but I’m introducing a methodology to implement the same approach and achieve the same functionality as variable variables.
Read more…

PHP: get and set custom HTTP headers

5.01.2012 | 4 Comments

In this short tutorial I will illustrate how can you send and read custom HTTP headers using php.

First let’s start by sending a custom HTTP header to the server. I will be using cURL library to send HTTP requests.

Read more…

Cakephp: Pagination sorting from foreign fields (fields from associated models)

3.06.2012 | 1 Comment

I came across a problem while developing with cakephp 2.0.

Suppose that you have got a Post model and a Category model, and you have a grid, with all posts and the category title they belong to. In order to sort by the category title you will need to do as the following in your view.

echo $this->Paginator->sort('Category.title','labelForTheTableHeader');

Hope that helps anyone

Egypt’s Mobile Number Change

11.06.2011 | 2 Comments

I’ve developed a snipped to correct the old numbers with the new numbers

The number change schema as follows:

(old -> new)


012 XXX XXXX -> 0122 XXX XXXX
017 XXX XXXX -> 0127 XXX XXXX
018 XXX XXXX -> 0128 XXX XXXX
0150 XXX XXXX -> 0120 XXX XXXX


011 XXX XXXX -> 0111 XXX XXXX
014 XXX XXXX -> 0114 XXX XXXX
0152 XXX XXXX -> 0112 XXX XXXX


010 XXX XXXX -> 0100 XXX XXXX
016 XXX XXXX -> 0106 XXX XXXX
019 XXX XXXX -> 0109 XXX XXXX
0151 XXX XXXX -> 0101 XXX XXXX

so here is my little php function that will use regular expressions

function changeMobileNumbers(&$contents){
	// vodafone
	$contents = preg_replace('/(0151)([0-9]{7})/', '0101$2', $contents);
	$contents = preg_replace('/(010)([0-9]{7})/', '0100$2', $contents);
	$contents = preg_replace('/(016)([0-9]{7})/', '0106$2', $contents);
	$contents = preg_replace('/(019)([0-9]{7})/', '0109$2', $contents);
	// etisalat
	$contents = preg_replace('/(0152)([0-9]{7})/', '0112$2', $contents);
	$contents = preg_replace('/(011)([0-9]{7})/', '0111$2', $contents);
	$contents = preg_replace('/(014)([0-9]{7})/', '0114$2', $contents);
	// mobinil
	$contents = preg_replace('/(0150)([0-9]{7})/', '0120$2', $contents);
	$contents = preg_replace('/(012)([0-9]{7})/', '0122$2', $contents);
	$contents = preg_replace('/(017)([0-9]{7})/', '0127$2', $contents);
	$contents = preg_replace('/(018)([0-9]{7})/', '0127$2', $contents);
	return $contents;

Hope that was useful

Installing LAMP with PHP 5.3 on Ubuntu 11.04 Natty Narwhal / 11.10 Oneric Ocelot

5.20.2011 | 12 Comments

I wont cover what’s new in php 5.3 since it would be another article, however it contains alot of improvements including PHP Namespaces, Late Static Bindings, lambda functions, closures…etc. I would strongly recommend using it.

I’ll be explaining how to install LAMP stack with PHP 5.3.8 without compiling

It’s fairly easy using the dotdeb repository

Read more…

Create RSS Feeds with Zend Framework

3.25.2011 | 8 Comments

In this post I’ll introduce how to create RSS feeds using Zend Framework through Zend_Feed Component.

We have got some mandatory elements in the channel, and the articles. Every Channel has to have the title, description, link and description elements. The articles also have some mandatory fields, as title, link, GUID (Globally Unique Identifier) and you can import as optional parameters as you want. Read more…