下面的代码通过array_shift()函数加while循环不断移除数组的第一个元素,直到数组为空
<?php $alpha = array("a", "b", "c"); while ( count( $alpha ) ) { $val = array_shift( $alpha); print "$val<br />"; print "there are ".count( $alpha )." elements in \$alpha <br />"; } ?>
下面的代码通过array_shift()函数加while循环不断移除数组的第一个元素,直到数组为空
<?php $alpha = array("a", "b", "c"); while ( count( $alpha ) ) { $val = array_shift( $alpha); print "$val<br />"; print "there are ".count( $alpha )." elements in \$alpha <br />"; } ?>