PHP JSONP 数据转换:如何将 JSON 数据转换为 PHP 数组
要将 JSON 数据转换为 PHP 数组,可以使用 json_decode 函数。该函数将 JSON 字符串解码为 PHP 数组。
示例代码如下:
$json = '{
'name': 'John',
'age': 30,
'city': 'New York'
}';
$array = json_decode($json, true);
print_r($array);
输出结果:
Array
(
[name] => John
[age] => 30
[city] => New York
)
在上面的示例中,我们通过 json_decode 函数将 JSON 字符串解码为 PHP 数组,并使用 print_r 函数打印数组的内容。
原文地址: https://www.cveoy.top/t/topic/mrS0 著作权归作者所有。请勿转载和采集!