It\'s as easy as the title sounds; I need to get the index/key of the last inserted item. Why is this difficult? See the following two code samples:
$a=array
You can use the end() function to get the last element in an array, and array_keys() to return an array of the array-keys. Confusing. In practice, it works like this:
$key = end(array_keys($array));
Credit goes to hollsk in the comments.