In PHP, an indexed array is a type of array where elements are assigned numeric keys automatically, starting from 0, or explicitly set by the programmer. Indexed arrays store multiple values in a single variable and are accessed using their numeric index.
You can create an indexed array using the array() function or square brackets []. For example:
php
$fruits = array(“Apple”, “Banana”, “Cherry”); Â
$colors = [“Red”, “Green”, “Blue”];
You can access elements by their index:
php
echo $fruits[0]; // Outputs: Apple
Indexed arrays are useful for ordered lists of data, such as names or items, and can be looped through using for or foreach.