php get first element of an array

Get value of the first element of the associative array:


$array = array( 4 => 'orange', 7 => 'banana', 55 => 'kiwi' );

$first_elem_of_array = array_shift( array_values( $array ) ); // returns 'orange'

Leave a Comment