Is there a better way to do the following:
$array = array('test1', 'test2', 'test3', 'test4', 'test5'); // do a bunch of other stuff, probably a loop $array[] = 'test6'; end($array); echo key($array); // gives me 6
This will give the key of the most recently add array element.
Is there a better way to do this?
You could also do:
But I think your way makes it clear what you want to do, so you could whip something up like:
That’s about it.