Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:完成的很认真, 内容可以改一下,不一定也是合肥市
<?php //创建数组 $arr1 = array(); $arr2 = [1, 2, 3, ]; echo $arr2[2]; echo '<hr>'; //关联数组、索引数组,访问数组数据 $wh=[ 'hs' => '洪山区', 'wc' => '武昌区', 'xz' => '新洲区', 'ja' => '江岸区', 'hp' => '黄陂区', ]; print_r($wh); echo $wh['hs']; echo $wh['wc']; echo '<hr>'; $wh=[ '洪山区', '武昌区', '新洲区', '江岸区', '黄陂区', ]; print_r($wh); echo $wh[2]; echo '<hr>'; //二维数组、三维数组 $wh=[ '洪山区' => ['关山街', '狮子山街', '和平街',], '武昌区', '新洲区', '江岸区', '黄陂区', ]; print_r($wh); echo $wh['洪山区'][0]; echo '<hr>'; //二维数组循环,三维数组循环 $wh=[ 'hs' => '洪山区', 'wc' => '武昌区', 'xz' => '新洲区', 'ja' => '江岸区', 'hp' => '黄陂区', ]; foreach ($wh as $v){ echo $v; echo '<hr>'; } $wh3=[ ['hs' => ['关山街', '狮子山街', '和平街']], ['wc' => ['武昌区']], ['xz' => ['新洲区']], ['ja' => ['江岸区']], ['hp' => ['黄陂区']], ]; foreach ( $wh3 as $qu ){ foreach ( $qu['hs'] as $jiedao ){ // print_r($jiedao); echo $jiedao; } echo '<hr>'; }
点击 "运行实例" 按钮查看在线实例