Using the PHP built-in function array_unshift, the following is an enumeration of the use of the Array_unshift function.
Array_unshift
The function is to insert one or more elements at the beginning of the array. Added elements as a whole add the same order of elements in the array as in the parameters. All the numeric key names in the modified array are modified to count from zero, and all the text keys remain unchanged. The function returns the number of elements in the array after the operation.
Syntax: int array_unshift (array & $array, mixed $var [, mixed $ ...])
For example:
| The code is as follows |
Copy Code |
<?php $queue = Array ("111cn.net", ". com"); Array_unshift ($queue, "apple", "raspberry"); Print_r ($queue); The above routines will output: Array ( [0] => Apple [1] => Raspberry [2] => 111cn.net [3] =>. com ) |
Of course we can use other methods directly, such as creating an array and assigning him a value.