What is a PHP array?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for PHP development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
A PHP array is a versatile ordered map that can store multiple values of any type under named keys or auto-incremented integer indices. PHP supports three types: Indexed arrays with numeric keys ($fruits = ["apple", "banana", "cherry"]), Associative arrays with string keys ($person = ["name" => "Alice", "age" => 25]), and Multidimensional arrays (arrays containing other arrays). PHP arrays are dynamic — they can grow or shrink at runtime, and a single array can mix integer and string keys. Unlike many languages, PHP arrays are actually ordered hash maps, so they maintain insertion order.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.