PHPPHP10 min read

Arrays in PHP: Indexed and Associative

Work with lists of data using indexed and associative arrays in PHP.

Natalie Scott
December 21, 2025
0.0k0

Arrays store multiple values in one variable. ## Indexed arrays ```php $fruits = ["Apple", "Banana", "Orange"]; echo $fruits[0]; // Apple ``` ## Associative arrays ```php $user = [ "name" => "Emma", "email" => "emma@test.com", "age" => 28 ]; echo $user["name"]; ``` ## Loop through arrays ```php foreach ($user as $key => $value) { echo "$key: $value<br>"; } ``` ## Useful array functions ```php count($fruits); array_push($fruits, "Mango"); ``` > Next: PHP functions to organize code.

#PHP#Arrays#Beginner