第12课时: 数组的定义和遍历视频教程

<p>掌握PHP中数组遍历的语法结构 示例如下&nbsp;</p> <pre> <code class="language-php">$cars = []; //购物车的数组 遍历 $cars['手机'] = '1000'; $cars['电视'] = '500'; $cars['冰箱'] = '1560'; $cars['洗衣机'] = '2200'; $cars[] = '2200'; $cars[] = '4351'; $cars[] = '543'; foreach($cars as $k =&gt; $v){ echo $k . '---' . $v . '&lt;br&gt;'; }</code></pre> <p>&nbsp;</p> <p>&nbsp;</p>
查看该视频教程