Adding array elements : array_push « Data Structure « PHP






Adding array elements

 
<html>

 <body>
 <ol>

 <?php
  $arr = array( "Red ","Green ","Blue" );

  array_unshift( $arr, "Cyan", "Magenta" );

  array_push( $arr, "Yellow", "Black" );
  
  foreach( $arr as $value)
  {
    echo( "<li>Do you like $value ?</li>");
  }
  ?>

  </ol>
 </body>
</html>
  
  








Related examples in the same category

1.Adding an Element to the End of an Array
2.array_push( ) pushes value onto the end of the array
3.array_push() function appends one or more values 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