Negative Array Indexes | PHP 8.3

Опубликовано: 01 Апрель 2026
на канале: Metaphorically Speaking
259
17

When looking for what's new and coming up in PHP 8.3, I learned about an interesting bug fix for array indexes which will also be a breaking change.

Backwards compatibility is important for PHP and, if you rely on the existing behaviour - you will need to update your code when updating to PHP 8.3

Now, when adding an item to an array without specifying an index (and it already contains an index with a negative integer) the new index will now proceed the previous.

This is quite a tricky one to put into words - so check out the video for an example.

Hat-tip to ‪@nunomaduro‬ and ‪@phpannotated‬ as I learned about this from their content. If you haven't already - go check out their content!

---

Website: https://acairns.co.uk
Twitter:   / andrewcairns  
Patreon:   / metaphoricallyspeaking  
Discord: https://acairns.co.uk/discord
Substack: https://acairns.substack.com

#php