我试图从PHP变量中获取此后续JSON数组的值。
这是数组的var_dump:
array(1) { [0]=> object(stdClass)#1 (1) { ["row"]=> object(stdClass)#2 (1) { ["u_fname"]=> string(6) "Ashish" } } }
这是我的页面代码
$
字符只是window.jQuery
的快捷方式。
$contents = file_get_contents('http://localhost/skillbook/json.php');
$contents = utf8_encode($contents);
$results =var_dump(json_decode($contents));
?>
答案 0 :(得分:1)
$contents = file_get_contents('http://localhost/skillbook/json.php');
$contents = utf8_encode($contents);
$contents_array = json_decode($contents,1);
$foundvalue= $contents_array[0]["row"]["u_fname"];
echo $foundvalue;
OutPut: Ashish
答案 1 :(得分:0)
我认为你可以为json使用foreach条件
$json = file_get_contents('http://localhost/skillbook/json.php');
$json = utf8_encode($json);
$data = json_decode($json,true);
// change the variable name to devices which is clearer.
$devices = $data['0'];
foreach ($devices as $device)
{
echo $device["u_fname"];
}