本文介绍了php:循环遍历 json 数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 json 数组:
[{"var1": "9","var2": "16",var3":16"},{"var1": "8","var2": "15",var3":15"}]如何使用 php 遍历这个数组?
解决方案
如果需要关联数组,请将第二个函数参数设置为 true
$json = '[{"var1":"9","var2":"16","var3":"16"},{"var1":"8","var2":"15","var3":"15"}]';$array = json_decode( $json, true );
I have a json array:
[
{
"var1": "9",
"var2": "16",
"var3": "16"
},
{
"var1": "8",
"var2": "15",
"var3": "15"
}
]
How can I loop through this array using php?
解决方案
Set the second function parameter to true if you require an associative array
$json = '[{"var1":"9","var2":"16","var3":"16"},{"var1":"8","var2":"15","var3":"15"}]';
$array = json_decode( $json, true );
这篇关于php:循环遍历 json 数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!