FreeKB - Append values to the end of an array (array_push)
PHP - Append values to the end of an array (array_push)

If you are not familiar with arrays, check out our Getting Started article.

Let's say you have an array of fruit.

$fruit = array("apple", "banana", "orange");


array_push can be used to add values to the end of an array. In this example, grapes is added to the fruit array.

array_push($fruit, "grapes");


var_dump can be used to print the data structure of the array.



Which will show that grapes was appended to the array.

array(4) { [0]=> string(5) "apple" [1]=> string(6) "banana" [2]=> string(6) "orange" [3]=> string(6) "grapes" }


Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter c3dc6 in the box below so that we can be sure you are a human.