Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php中的多维关联数组_Php_Arrays_Json_Associative Array - Fatal编程技术网

php中的多维关联数组

php中的多维关联数组,php,arrays,json,associative-array,Php,Arrays,Json,Associative Array,下面我需要一些关于关联数组的指南,如何访问或检索指定的值,例如JSON格式的student_详细信息中student_名称“Kevin”下的高度 <?php $college=[ 'college_id' => '123', 'student_details'=> [ 'student_name'=>[ 'Kevin'=> [ 'height'=>'170',

下面我需要一些关于关联数组的指南,如何访问或检索指定的值,例如JSON格式的student_详细信息中student_名称“Kevin”下的高度

<?php
$college=[
    'college_id' => '123',
    'student_details'=> [
        'student_name'=>[
            'Kevin'=> [
                'height'=>'170',
                'weight'=>'65',
            ],
            'Daniel'=> [
                'height'=>'170',
                'weight'=>'65',
            ] ,
            'Paul'=> [
                'height'=>'179',
                'weight'=>'70',
            ]
        ]
    ]
];
echo json_encode($college);
?>

如果使用
$array=json\u decode($json,true)


为什么要尝试在PHP中处理JSON?您应该只操作数组并将其转换为JSON进行输出。如果我需要将此数组以JSON编码形式传递到另一个页面,我应该如何访问其中的值?另一个页面是PHP还是JavaScript?如果是PHP,那么你可以使用
json\u decode()
PHP,在我使用了json decode之后,我应该如何访问我上面提到的指定数据,例如学生详细信息中学生姓名“Kevin”下的高度请在下面检查我的答案Hanks bro,这非常有帮助
<?php
echo $array['student_details']['student_name']['Kevin']['height'];
?>
<?php
echo $object->student_details->student_name->Kevin->height;
?>