Created
July 23, 2013 20:21
-
-
Save PabloVallejo/6065798 to your computer and use it in GitHub Desktop.
Get index of last inserted element in array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create array | |
$a = array(); | |
// Add an item to it | |
$a[] = 1; | |
// Point to the last index of the array | |
end( $a ); | |
// Get the index | |
$last_id = key( $a ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment