Skip to content

Instantly share code, notes, and snippets.

This is a collection of working solutions in PHP found all over internet to check two things:
1. Whether a given variable is an indexed array. An indexed array in PHP is an array where all keys are sequential, numerical and starts from 0, ie, which is like vector in other languages. The tests can be found here: https://3v4l.org/fcZ2j
2. Whether a given variable is an associative array. An associative array is the opposite of above case where keys need not be numeric, sequential or starting from zero. The tests can be found here: https://3v4l.org/fcZ2j