php通过array_shift()函数移除数组第一个元素的方法
本文实例讲述了php通过array_shift()函数移除数组第一个元素的方法。分享给大家供大家参考。具体分析如下:
下面的代码通过array_shift()函数加while循环不断移除数组的第一个元素,直到数组为空
<?php $alpha=array("a","b","c"); while(count($alpha)){ $val=array_shift($alpha); print"$val<br/>"; print"thereare".count($alpha)."elementsin\$alpha<br/>"; } ?>
希望本文所述对大家的php程序设计有所帮助。