PHP arrays are ordered maps — they can behave as indexed lists, associative dictionaries, or even a mix of both.
Indexed arrays (numeric keys, usually auto-assigned starting at 0):
$colors = ['red', 'green', 'blue'];
echo $colors[0]; // 'red'
$colors[] = 'yellow'; // append to the end
Associative arrays (string keys):
$person = [
'name' => 'Alice',
'age' => 30,
'city' => 'Dhaka',
];
echo $person['name']; // 'Alice'
$person['email'] = 'alice@example.com'; // add a new key
unset($person['age']); // remove a key
Multidimensional arrays nest arrays inside arrays — common for representing rows of data:
$users = [
['name' => 'Alice', 'age' => 30],
['name' => 'Bob', 'age' => 25],
];
echo $users[0]['name']; // 'Alice'
Check existence with isset($arr['key']) or array_key_exists('key', $arr) (the latter also returns true for keys whose value is null). Count elements with count($arr). Loop with foreach, as shown in the Control Structures chapter.