-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassocArray.php
More file actions
47 lines (45 loc) · 1.04 KB
/
assocArray.php
File metadata and controls
47 lines (45 loc) · 1.04 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
$myArray = [
[
"name" => "John Doe",
"email" => "john@example.com",
"age" => 25,
"city" => "New York",
"profession" => "Developer"
],
[
"name" => "Jane Smith",
"email" => "jane@example.com",
"age" => 30,
"city" => "Los Angeles",
"profession" => "Designer"
],
[
"name" => "Michael Johnson",
"email" => "michael@example.com",
"age" => 35,
"city" => "Chicago",
"profession" => "Engineer"
],
[
"name" => "Emily Davis",
"email" => "emily@example.com",
"age" => 28,
"city" => "San Francisco",
"profession" => "Product Manager"
],
[
"name" => "Any Jason",
"email" => "anyjason@example.com",
"age" => 29,
"city" => "London",
"profession" => "PHP Developer"
]
];
$index = 1;
if (isset($myArray[$index]['email'])) {
echo "City: " . $myArray[$index]['email'];
} else {
echo "City not found at index " . $index;
}
?>