Checking if a key is the last element in an array?

arrays, php

Solution

You could use end() and key() to get the key at the end of the array.

end($array);
$lastKey = key($array);

Problem

How can I check if this key is the last element in an array? ``` $array = array("a","b","c"); ``` The value "c" would have the key 2. Is there some code like this `is_end(2)` which returns true or false depending if they key is the last of the array? Is there some kind of `while()` statement I can use?

Original source

Related problems