php通過array_shift()函數(shù)移除數(shù)組第一個元素的方法
更新時間:2015年03月18日 11:24:24 作者:work24
這篇文章主要介紹了php通過array_shift()函數(shù)移除數(shù)組第一個元素的方法,涉及php中array_shift()函數(shù)操作數(shù)組的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了php通過array_shift()函數(shù)移除數(shù)組第一個元素的方法。分享給大家供大家參考。具體分析如下:
下面的代碼通過array_shift()函數(shù)加while循環(huán)不斷移除數(shù)組的第一個元素,直到數(shù)組為空
<?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 />"; } ?>
希望本文所述對大家的php程序設計有所幫助。
您可能感興趣的文章:
- php數(shù)組函數(shù)array_push()、array_pop()及array_shift()簡單用法示例
- PHP array_shift()用法實例分析
- php中array_slice和array_splice函數(shù)解析
- PHP中unset,array_splice刪除數(shù)組中元素的區(qū)別
- 解析array splice的移除數(shù)組中指定鍵的值,返回一個新的數(shù)組
- php數(shù)組函數(shù)序列之a(chǎn)rray_splice() - 在數(shù)組任意位置插入元素
- js利用Array.splice實現(xiàn)Array的insert/remove
- Array.slice()與Array.splice()的返回值類型
- php去掉數(shù)組的第一個值的兩個函數(shù):array_shift、array_splice
相關文章
PHP similar_text 字符串的相似性比較函數(shù)
PHP尋找兩個字符串的相似性的similar_text ()函數(shù)使用方法2010-05-05