Home>Article>Backend Development> How to modify array with php array_push()
In PHP, the array_push() function modifies the array by inserting one or more elements at the end of the array, and then returns the length of the array after inserting the new elements; use the syntax "array_push(array,value1,value2 ...)".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php array_push() function-- Modify the array by inserting elements at the end of the array
array_push() function adds one or more elements (push) to the end of the array of the first parameter, and then returns the Array length.
Grammar format:
array_push(array,value1,value2...)
Parameter description:
array Required, indicating an array;
value1, value2, ... represent the elements (values) that need to be inserted.
array_push() treats array as a stack and pushes the passed elements into the end of array. The length of array will increase according to the number of elements pushed onto the stack.
Example:
Output result:
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to modify array with php array_push(). For more information, please follow other related articles on the PHP Chinese website!