实例
<?php echo'<h3>一维数组</h3>'; $arr = ['php中文网', '你好!我的世界','好好学习']; echo'<h4>带KEY输出</h4>'; print_r ($arr); echo'<br>'; echo'<h4>带KEY和数据类型输出</h4>'; var_dump($arr); echo'<hr>'; echo $arr; echo'<h3>关联数组</h3>'; $diming =[ 'hainan'=>'海南', 'henan'=>'河南', 'hefei'=>'合肥' ]; print_r ($diming); echo'<hr>'; echo'<h3>二维数组</h3>'; $chengshi=[ ['sheng'=>'海南', 'cheng'=>'海口'], ['sheng'=>'河南', 'cheng'=>'郑州'], ['sheng'=>'安徽', 'cheng'=>'合肥'] ]; print_r($chengshi); echo'<hr>'; echo'<h3>三维数组</h3>'; $chengshi=[ ['sheng'=>'海南', 'cheng'=>'海口',['bianhao'=>'1']], ['sheng'=>'河南', 'cheng'=>'郑州',['bianhao'=>'2']], ['sheng'=>'安徽', 'cheng'=>'合肥',['bianhao'=>'3']] ]; print_r($chengshi); echo'<hr>'; echo'<h3>三维数组循环</h3>'; foreach($chengshi as $shuchu){ print_r($shuchu) ; echo'<hr>'; } ?>
运行实例 »
点击 "运行实例" 按钮查看在线实例
老师 你好 !
为什么我用 echo 总报错呢?百度看的不太明白!