No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

array_unshift

(PHP 4, PHP 5, PHP 7)

array_unshiftPrepend one or more elements to the beginning of an array

Description

array_unshift ( array &$array [, mixed $... ] ) : int

array_unshift() prepends passed elements to the front of the array. Note that the list of elements is prepended as a whole, so that the prepended elements stay in the same order. All numerical array keys will be modified to start counting from zero while literal keys won't be changed.

PHP: array_unshift - Manual Home of Manuel PHP  Contents Haut

Parameters

array

The input array.

...

The values to prepend.

PHP: array_unshift - Manual Home of Manuel PHP  Contents Haut

Return Values

Returns the new number of elements in the array.

PHP: array_unshift - Manual Home of Manuel PHP  Contents Haut

Changelog

Version Description
7.3.0 This function can now be called with only one parameter. Formerly, at least two parameters have been required.

PHP: array_unshift - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 array_unshift() example

<?php
$queue 
= array("orange""banana");
array_unshift($queue"apple""raspberry");
print_r($queue);
?>

The above example will output:

Array
(
    [0] => apple
    [1] => raspberry
    [2] => orange
    [3] => banana
)

PHP: array_unshift - Manual Home of Manuel PHP  Contents Haut

See Also

Find a PHP function
Error Infobrol

Can not display this page of the Infobrol website

Type of error (18-01)

Unknown format specifier "&"

Please try again in a few minutes…

Return to the home page




Steph