-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccessingAddingElements.php
More file actions
30 lines (18 loc) · 898 Bytes
/
AccessingAddingElements.php
File metadata and controls
30 lines (18 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
$favorites = ["favorite_food"=>"pizza", "favorite_place"=>"my dreams", "FAVORITE_CASE"=>"CAPS","favorite_person"=>"myself"];
echo $favorites["favorite" . "_" . "food"];
// Prints: pizza
$key = "favorite_place";
echo $favorites[$key];
// Prints: my dreams
echo $favorites[strtoupper("favorite_case")];
// Prints: CAPS
$assignment_one = ["Alex"=> 87, "Kenny"=> 91, "Natalia"=> 91, "Lily"=> 67, "Dan"=> 81, "Kat"=> 77, "Sara" => 65];
$assignment_two = ["Alex"=> 91, "Kenny"=> 99, "Natalia"=> 100, "Lily"=> 61, "Dan"=> 88, "Kat"=> 90];
$assignment_three = ["Alex"=> 78, "Kenny"=> 92, "Natalia"=> 94, "Lily"=> 79, "Dan"=> 73, "Sara" => 61];
$student_name = "Alex";
// Write your code below:
$assignment_two["Sara"] = 65;
$assignment_three["Kat"] = 97;
$dans_grades = [$assignment_one["Dan"], $assignment_two["Dan"], $assignment_three["Dan"]];
echo $assignment_two[$student_name];