有人能告诉我这两个循环/代码片段之间有什么区别吗?
我得到相同的输出,但是教科书表明外圈和内圈有区别?任何澄清都会有所帮助.我不认为我理解每个功能的列表.
数组定义:
$newArray = array(array('CODE' => 'TIR','Description' =>'TIRES','Price' => 100),array('CODE' => 'OIL','Description' => 'Oil','Price' =>10),array('CODE' => 'SPK','Description' => 'Spark Plug','Price' =>40) );
代码段1:
for ($row = 0; $row < 3; $row ++) { echo ' |'.$newArray[$row]['CODE'].'| '.$newArray[$row]['Description']. '| '.$newArray[$row]['Price']; echo '<br />'; echo '<br />'; }
代码段2:
for ($row =0; $row <3; $row ++) { while (list($key,$value) = each ($newArray[$row])) { echo "|$value"; } echo '<br />'; echo '<br />'; }