Mega Code Archive

 
Categories / Php / Data Type
 

Removing the First Element of an Array with array_shift()

array_shift() removes and returns the first element of an array passed to it as an argument.  <?php $an_array = array("a", "b", "c"); while ( count( $an_array ) ) {   $val = array_shift( $an_array);   print "$val<br />";   print "there are ".count( $an_array )." elements in \$an_array <br />"; } ?>