21. Introduction to Indexed Arrays
Arrays are special variables that can hold more than one value under a single name. Indexed arrays use numbers (starting from 0) as keys to access the values.
Creating Indexed Arrays
PHP offers two main syntaxes for creating arrays:
-
The traditional
array()constructor: php -
The short array syntax (recommended, PHP 5.4+): php
Accessing and Modifying Elements
Elements are accessed using their index, enclosed in square brackets [].
php
"; print_r($planets); echo ""; ?>