php convert array to query string

Now you can eaisly convert an array to query string in php.No need to do any code for that php has inbuilt function for converting array into query string.If you are using php 5 then you can use inbuilt function of php called “http_build_query()”.

http_build_query() :

Defination : string  http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )

Example

$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');

echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&');

Out Put :

foo=bar&baz=boom&cow=milk&php=hypertext+processor
foo=bar&baz=boom&cow=milk&php=hypertext+processor