实例
<?php $arr1 = array(0, 'one', 2.2, true, null); $arr2 = [0, 'one', 2.2, true, null]; $arr3 = [ [ 'name' => 'jason', 'number'=>1111, 'age' => 15, 'hobbies'=> [ 'badminton', 'skiing', 'cooking' ] ], [ 'name'=>'james', 'number'=>2222, 'age'=>16, 'hobbies'=>[ 'music', 'tennis', 'biking' ] ], [ 'name'=>'jack', 'number'=>3333, 'age'=>17, 'hobbies'=>[ 'swimming', 'reading', 'coding' ] ]]; foreach ($arr3 as $k=>$v){ echo 'name: '.$v['name'].'<br>'; echo 'number: '.$v['number'].'<br>'; echo 'age: '.$v['age'].'<br>'; echo 'hobbies: '; foreach ($v['hobbies'] as $key=>$hobbies){ echo $hobbies.' '; } echo'<hr>'; } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例