Associative arrays are arrays that use custom named keys assigned to their elements.
$car |
To access an array item, you can refer to its key name.
Show the car’s model:
$car |
To modify the value of an array item, use its key name:
Update the year item:
$car |
To iterate through and print all the values of an associative array, you can use a foreach loop, like this:
Output all items in the array, including both keys and values:
$car foreach |