将字符串更改为数组是
$string = '[{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}]';
$array = json_decode($array,true);
但是如果反向将数组更改为字符串
$array = [{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}];
$string = $array; // $string is $string like on first example
答案 0 :(得分:0)
您可以将json_encode用作:
$string = '[{"name":"jack","address":"who knows"},{"name":"jill","address":"who knows too"}]';
$array = json_decode($string,true); // convert string -> array
$string = json_encode($array); // convert array -> string
echo $string; // will output the original string