Back to Developer Roadmap

Multi-dimensional Arrays

src/data/roadmaps/php/content/[email protected]

4.0840 B
Original Source

Multi-dimensional Arrays

Multi-dimensional arrays in PHP are a type of array that contains one or more arrays. Essentially, it's an array of arrays. This allows you to store data in a structured manner, much like a table or a matrix. The fundamental idea is that each array value can, in turn, be another array. For instance, you can store information about various users, where each user (a primary array element) contains several details about them (in a secondary array like email, username etc.).

Here's an example:

$users = [
       ["John", "[email protected]", "john123"],
       ["Jane", "[email protected]", "jane123"],
       ["Doe", "[email protected]", "doe123"]
];

Visit the following resources to learn more: