-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray_exercise.php
More file actions
53 lines (45 loc) · 897 Bytes
/
array_exercise.php
File metadata and controls
53 lines (45 loc) · 897 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// Basic syntax
$numbers = array(
1,
2,
3,
4,
5
);
var_dump($numbers).PHP_EOL;
print_r($numbers).PHP_EOL;
// New syntax
$numbers2 = [
1,
2,
3,
4,
5
];
var_dump($numbers2).PHP_EOL;
print_r($numbers2).PHP_EOL;
echo $numbers2[3].PHP_EOL;
$contactInfo = [
'first_name' => 'Tinky',
'last_name' => 'Winky',
'email' => 'twinky@teletubbies.org',
'phone' => '210-867-5309'
];
$test = [
'person1' => $contactInfo,
'person2'=> [
'first_name' => 'Barney',
'last_name' => 'Dinosaur',
'email' => 'barney.n.friends@hotmail.com',
'phone' => '202-555-0123'
],
'person3' => [
'first_name' => 'Lamb',
'last_name' => 'Chop',
'email' => 'lchop@lchopsplayalong.net',
'phone' => '212-857-1051'
]
];
echo $test['person1']['email'] . PHP_EOL;
print_r($test).PHP_EOL;