I have an array:
array( 4 => \'apple\', 7 => \'orange\', 13 => \'plum\' )
I would like to get the first element of this array. Expect
No one has suggested using the ArrayIterator class:
$array = array( 4 => 'apple', 7 => 'orange', 13 => 'plum' ); $first_element = (new ArrayIterator($array))->current(); echo $first_element; //'apple'
gets around the by reference stipulation of the OP.