Home  >  Article  >  Backend Development  >  php-Arrays函数-array_shift-移除数组开头的一个单元_PHP教程

php-Arrays函数-array_shift-移除数组开头的一个单元_PHP教程

WBOY
WBOYOriginal
2016-07-13 17:51:23915browse

array_shift() 移除数组开头的一个单元

【功能】
         该函数将弹出并返回array数组的开头一个单元,然后将数组的长度减一
         所有数字键名将改为从零开始计数
         如果array为空或不是数组将返回null
【使用范围】
         php4、php5.
【使用】
         mixed array_shift( array &array )
         array/必需/即将进行函数处理数组
【示例】
[php]
$array = array('orange','banana','apple'); 
var_dump($array); 
var_dump(array_shift($array)); 
var_dump($array); 
/*
array(3) {
  [0]=>
  string(6) "orange"
  [1]=>
  string(6) "banana"
  [2]=>
  string(5) "apple"
}
string(6) "orange"
array(2) {
  [0]=>
  string(6) "banana"
  [1]=>
  string(5) "apple"
}
*/ 

 


摘自 zuodefeng的笔记

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478191.htmlTechArticlearray_shift() 移除数组开头的一个单元 【功能】 该函数将弹出并返回array数组的开头一个单元,然后将数组的长度减一 所有数字键名将改为从...
Statement:
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