在PHP中,可以使用json_decode()函数将JSON字符串转换为JSON数组。该函数的语法如下:
json_decode($json_string, true);
其中,$json_string是要转换的JSON字符串,true参数表示将JSON对象转换为关联数组。
以下是一个示例:
$json_string = '[{"name":"John", "age":30, "city":"New York"}, {"name":"Jane", "age":25, "city":"Los Angeles"}]';
$json_array = json_decode($json_string, true);
print_r($json_array);
输出结果为:
Array
(
[0] => Array
(
[name] => John
[age] => 30
[city] => New York
)
[1] => Array
(
[name] => Jane
[age] => 25
[city] => Los Angeles
)
)
上一篇:如何数组化操作对象php
下一篇:php数组求和函数怎么算
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站