Rumah >pembangunan bahagian belakang >tutorial php >PHP数组输出
Array ( [0] => 黑灰/L(170/95) [1] => 7.62 [2] => 藏青/XXL(180/105) [3] => 12.6 [4] => 花灰/L(170/95) [5] => 5.2 [6] => 藏青/XXXL(185/110) [7] => 6.62 [8] => 黑灰/XL(175/100) [9] => 9.96 [10] => 花灰/XXXL(185/110) [11] => 1.51 [12] => 花灰/XL(175/100) [13] => 6.73 [14] => 黑灰/XXL(180/105) [15] => 5.73 [16] => 藏青/XL(175/100) [17] => 22.27 [18] => 黑灰/XXXL(185/110) [19] => 3.05 [20] => 藏青/L(170/95) [21] => 15.17 [22] => 花灰/XXL(180/105) [23] => 3.54 )
foreach($ceshi as $k => $value){ if($k % 2 == 1) echo $value; } foreach($ceshi as $k => $value){ if($k % 2 == 0) echo $value; }
for($i=1; $i<count($ceshi); $i+=2) echo $ceshi[$i];for($i=0; $i<count($ceshi); $i+=2) echo $ceshi[$i];
$num=sizeof($ceshi);for($i=1;$i<$num;$i++){ $j=1+($i-1)*2; if($j>$num) break; echo $ceshi[$j];}for($x=1;$x<$num;$x++){ $y=2*($x-1); if($y>$num) break; echo $ceshi[$y];}