array_push() function appends one or more values onto the end of the array. : array_push « Data Structure « PHP






array_push() function appends one or more values onto the end of the array.

 
//Its syntax is: int array_push(array array, mixed var, [. . . ])

<?
    $languages = array("A", "B", "C");
    array_push($languages, "Russian", "German", "Gaelic");
    print_r($languages);
?>

==
array_pop() function removes a value from the end of the array. This value is then returned. 

//Its syntax is: mixed array_pop(array array)

//Each iteration of array_pop() will shorten the length of the array by 1. 

<?
    $languages = array ("Spanish", "English", "French", "Gaelic");
    $a_language = array_pop ($languages); 
    print $a_language;
    $a_language = array_pop ($languages);
    print_r( $a_language); 
?>
  
  








Related examples in the same category

1.Adding an Element to the End of an Array
2.Adding array elements
3.array_push( ) pushes value onto the end of the array
4.Push one or more elements onto the beginning of array
5.Push one or more elements onto the end of array