Multi-dimensional Arrays
Last updated
What is 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", "john@example.com", "john123"],
["Jane", "jane@example.com", "jane123"],
["Doe", "doe@example.com", "doe123"]
];
Free resources to learn Multi-dimensional Arrays
- Official docsMulti-dimensional Arrays
More in stage 3: Arrays
Multi-dimensional Arrays: common questions
Can I learn Multi-dimensional Arrays in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Multi-dimensional Arrays in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Multi-dimensional Arrays tutorial for beginners?
It is lesson 9 of 120 in the free PHP roadmap, in stage 3, Arrays. If you are new to PHP, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.