PHP数组输出

WBOY
Release: 2016-06-23 13:46:14
Original
899 people have browsed it

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 )
Copy after login


$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;		}
Copy after login

for($i=1; $i<count($ceshi); $i+=2) echo $ceshi[$i];for($i=0; $i<count($ceshi); $i+=2) echo $ceshi[$i];
Copy after login

$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];}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template