php中的多维关联数组
下面我需要一些关于关联数组的指南,如何访问或检索指定的值,例如JSON格式的student_详细信息中student_名称“Kevin”下的高度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',
<?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;
?>