Indexed Arrays

Last updated

What is Indexed Arrays?

Indexed arrays in PHP store values that are accessed through numerical indexes, which start at 0 by default. This might be particularly useful when you have a list of items in a specific order. For example, you might use an indexed array to represent a list of your favorite books, where each book is numbered starting from 0. Each individual item in the array, book in this case, can be accessed by their specific index. You can use the array() function or the short array syntax [] to declare an indexed array.

Here's an Example:

$books = ["The Great Gatsby", "Moby Dick", "To Kill a Mockingbird"];
echo $books[0]; //Outputs "The Great Gatsby"

Free resources to learn Indexed Arrays

More in stage 3: Arrays

Indexed Arrays: common questions

Can I learn Indexed 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 Indexed 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 Indexed Arrays tutorial for beginners?

It is lesson 7 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.

Still confused? Ask me