http_build_query($array)
will convert array to the format of a=1&b=2
,
But how to make it convert to the format of a=1;b=2
?
Is there a native function there?
The third parameter to http_build_query is the separator; call it with http_build_query($array, "", ";")
to get what you're after.
http_build_query()
can do that as of PHP 5.1.2. For example:
$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data, '', ';');
As you can see the third parameter is the arg_separator
and can be any string you like.
Output from the above example would be:
foo=bar;baz=boom;cow=milk;php=hypertext+processor