Skip to content

Instantly share code, notes, and snippets.

@PabloVallejo
Created July 23, 2013 20:21
Show Gist options
  • Save PabloVallejo/6065798 to your computer and use it in GitHub Desktop.
Save PabloVallejo/6065798 to your computer and use it in GitHub Desktop.
Get index of last inserted element in array
<?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