已知json数组格式如下
{
"id":["1123","1377"],
"uid":["24542","84358"],
"sid":["37683","99089"],
"pid":["44354","1900"],
"gid":["5565","7280"],
"oid":["34166","7890987"]
}
{
"id":["1123","1377"],
"uid":["24542","84358"],
"sid":["37683","99089"],
"pid":["44354","1900"],
"gid":["5565","7280"],
"oid":["34166","7890987"]
}
foreach key value 即可,代码如下:
<?php
$json = '{
"id":["1123","1377"],
"uid":["24542","84358"],
"sid":["37683","99089"],
"pid":["44354","1900"],
"gid":["5565","7280"],
"oid":["34166","7890987"]
}';
$json = json_decode($json,true);
foreach($json as $key=>$value){
echo "$key 第一个: $value[0] 第二个: $value[1]\n";
}