When using []
to dynamically set array values, how do you get the last key that was filled?
For example, consider:
$array[] = 'apple';
$array[] = 'banana';
$array[] = 'orange';
How do you get the last key value (in this case 2
for "orange")?
The key()
function is just returning 0
no matter which line I place it after.