PHPPHP10 min read

Arrays in PHP: Indexed and Associative

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

Natalie Scott
September 20, 2025
8.1k299

Arrays store multiple values in one variable.

Indexed arrays

$fruits = ["Apple", "Banana", "Orange"];
echo $fruits[0]; // Apple

Associative arrays

$user = [
  "name" => "Emma",
  "email" => "emma@test.com",
  "age" => 28
];

echo $user["name"];

Loop through arrays

foreach ($user as $key => $value) {
  echo "$key: $value<br>";
}

Useful array functions

count($fruits);
array_push($fruits, "Mango");

Next: PHP functions to organize code.

#PHP#Arrays#Beginner