Example of array_push() function

array_push (arrName, varName) function in php

array_push() function use an array as a stack, and it pushes the passed variables at the end of the array. The length of the array increases automatically by the number of variables pushed into the array_push function. It accepts two parameters, the first parameter to be an array and the second parameter can be any type of value.

array_push : Point To be remembered:

array_push() function() create a warning if the first argument passed in array_push is not an array.

Example :


$fruits = array("apple", "grapes");

array_push($fruits, "papaya");




Output of array_push() function example
Output of array_push() function example






Leave a Reply

Your email address will not be published. Required fields are marked *