Advertisement

Google Ad Slot: content-top

PHP Access Arrays

~1 min read · PHP
On this page

To access an array item, refer to the index number for indexed arrays, and the key name for associative arrays.

Example
    
Try it yourself

Accessing Associative Arrays


In an associative array, elements are accessed using custom keys.

Example
"John", "age" => 30, "city" => "New York" ]; // Accessing elements by keys echo $person["name"]; // Outputs: John echo $person["age"]; // Outputs: 30 ?>
Try it yourself