array_push Php Example - Php

How to insert one or more elements at the end of array in php?

Snippet Code


  
Rate this page :
  [ 0 votes]

"array_push()" method inserts two array elements at the end of array. In this php code, array_push is used to append Blue , Red onto the Black, White in colors array.

<?php $colors=array("Black","White"); array_push($colors,"Blue","Red"); print_r($colors); ?>

Tags


Ask Questions

Ask Question