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