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 )
$ceshi 数组如上先输出13579...... 在输出02468..
注 $ceshi数组 可能100+个也可能就10几个
求大神解答
回复讨论(解决方案)
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
$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];}