juniorPHP

What are arrays in PHP?

Updated May 24, 2026

Short answer

Arrays store multiple values in a single variable and can be indexed, associative, or multidimensional.

Deep explanation

PHP arrays are ordered maps capable of behaving as lists, dictionaries, stacks, and queues. Associative arrays use named keys, while indexed arrays use numeric indexes.

Real-world example

API responses are often stored and manipulated using associative arrays.

Common mistakes

  • Accessing undefined keys and confusing indexed arrays with associative arrays.

Follow-up questions

  • What is a multidimensional array?
  • How do you loop through arrays?

More PHP interview questions

View all →