Sometimes you need to identify the first and last elements of an array for use in a foreach loop. And in PHP this looks set to get a whole lot easier thanks to the new version 7.3, which is currently at Release Candidate status.
In previous versions of PHP you would’ve had to do something like this:
Now in PHP 7.3 and up, there are new functions called array_key_first and array_key_first, so you just need to call those:
If nothing else it certainly makes for much neater code.