Skip to content

Commit a4ce2e4

Browse files
009-Associative Arrays with Keys and Values
1 parent 672325e commit a4ce2e4

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

009-associative-arrays-with-keys-and-values.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,17 @@
1313
echo "\nMy second name is {$mixArray['secondName']}";
1414
echo "\nMy grandfather's age is {$mixArray[0]} years";
1515

16+
$myArray = [
17+
"fruits" => ["apple", "banana", "orange"],
18+
"vegetables" => ["carrot", "potato", "onion"],
19+
"meat" => ["beef", "pork", "chicken"],
20+
"dairy" => ["milk", "yogurt", "cheese"],
21+
"drinks" => ["water", "tea", "coffee"],
22+
"food" => ["pizza", "burger", "salad"],
23+
"sports" => ["tennis", "soccer", "basketball"]
24+
];
25+
26+
echo "My favorite food is {$myArray['food'][0]}\n";
27+
echo "My favorite sport is {$myArray['sports'][2]}\n";
28+
echo "My favorite drink is {$myArray['drinks'][0]}\n";
29+
echo "My favorite fruit is {$myArray['vegetables'][1]}\n";

0 commit comments

Comments
 (0)