-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_arrays.php
61 lines (50 loc) · 1.04 KB
/
03_arrays.php
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
54
55
56
57
58
59
60
61
<?php
/* ----------- Arrrays ----------- */
/*
Arrays hold multiple values. Each value in an array is called an "element"
*/
$numbers = [1, 2, 3, 4, 5];
$fruits = array('Apple', 'Banana', 'Orange', 'Mango');
// print_r($numbers);
// var_dump($numbers);
// echo $fruits[1];
// Associative Arrays
$colors = [
'red' => 'Apple',
'yellow' => 'Banana',
'orange' => 'Orange',
'green' => 'Mango'
];
// echo $colors['red'];
$hex = [
'red' => '#ff0000',
'yellow' => '#ffff00',
'orange' => '#ffa500',
'green' => '#008000'
];
// echo $hex['red'];
$person = [
'first_name' => 'Stefan',
'last_name' => 'Gogov',
'email' => 'stefan@gmail.com'
];
// echo $person['first_name'];
$people = [
[
'first_name' => 'Stefan',
'last_name' => 'Gogov',
'email' => 'stefan@gmail.com'
],
[
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john@gmail.com'
],
[
'first_name' => 'Martin',
'last_name' => 'Doe',
'email' => 'martin@gmail.com'
]
];
// echo $people[1]['email'];
var_dump(json_encode($people));