Im trying to remove the first element of the last array
The array:
$harbours = array(
'67' => array('boat1', 'boat2'),
'43' => array('boat3', 'boat4')
);
I want to remove and return boat3
$last = end($harbours);
$boat = array_shift($last);
If I then print_r ($harbours), ‘boat3’ is still there.
That is because in
array_shiftyou are changing a copy of the end array.You need to get a reference of the end array in order to shift it.
Try this:
See Demo: http://codepad.org/ey3IVfIL