search
Homephp教程php手册php-Arrays函数-array_unshift-在数组开头插入一个或多个单元

array_unshitf() 在数组的开头插入一个或多个单元

【功能】
         该函数将传入的单元插入到指定数组的开头
         注意单元是作为整体被插入的,因此传入单元将保持同样的顺序
         所有的数值键名将修改为从零开始重新计数,所有的文字键名保持不变
         最后返回数组新的单元数目
【使用范围】
         php4、php5.
【使用】
         int array_unshift( array &array,mixed var[,mixed...]  )
         &array/必需/即将插入操作原始数组
         var/必需/即将添加的值
【示例】
[php]
$array=array("orange","banana"); 
var_dump(array_unshift($array,'apple','raspberry')); 
var_dump($array); 
/*
int(4)
array(4) {
  [0]=>
  string(5) "apple"
  [1]=>
  string(9) "raspberry"
  [2]=>
  string(6) "orange"
  [3]=>
  string(6) "banana"
}
*/ 

 


摘自 zuodefeng的笔记

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.