If you want to make sure that you'll get exactly the same array back, you have to use serialize (as it'll keep variable types) and unserialize to get your data back. Alternately, json_decode and json_encode work as well (but only maintains simple types as int/float/string/boolean/NULL). The data will be larger than implode and http_build_query, though.
Examples:
Consider the following array:
$array = array(
'foo' => 'bar',
'bar' => false,
'rab' => null,
'oof' => 123.45
);
serialize/unserialize:
<?php
var_dump( unserialize( serialize($array) ) );
/*
array(4) {
["foo"] => string(3) "bar"
["bar"] => bool(false)
["rab"] => NULL
["oof"] => float(123.45)
}
*/
?>
implode/explode:
<?php
var_dump( explode('&', implode('&', $array) ) );
/*
array(4) {
[0] => string(3) "bar"
[1] => string(0) ""
[2] => string(0) ""
[3] => string(6) "123.45"
}
*/
?>
json_encode/json_decode:
<?php
var_dump( json_decode( json_encode($array) , true) );
/*
array(4) {
["foo"] => string(3) "bar"
["bar"] => bool(false)
["rab"] => NULL
["oof"] => float(123.45)
}
*/
?>
http_build_query/parse_str:
<?php
parse_str( http_build_query($array) , $params);
var_dump( $params );
/*
array(3) {
["foo"] => string(3) "bar"
["bar"] => string(1) "0"
["oof"] => string(6) "123.45"
}
*/
?>
DEMO