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 ]]] )


$data = array('foo'=>'bar',
'php'=>'hypertext processor');

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

Out Put :


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.