-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.php
More file actions
48 lines (48 loc) · 1.16 KB
/
arrays.php
File metadata and controls
48 lines (48 loc) · 1.16 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
48
<?php
//echo "We talk about Array<br>";
$some_numers = [1,3,4,6];
$fruits = array('pineapple', 'melon', 'apple');
// print_r($fruits);
// echo $fruits[2];
//associative array
$colors = [
3 => 'red',//key - values
5 => 'green',
7 => 'blue'
];
//echo $colors[7];
//key as a string
$hex_colors = [
'red' => '#FF0000',
'green' => '#00FF00',
'blue' => '#0000FF',
];
// echo $hex_colors['green'];
$person = [
'full_name' => 'Nguyen Duc Hoang',
'age' => 43,
'email' => 'sunlight4d@gmail.com'
];
//print_r($person);
//echo $person['email'];
$persons = [
[
'full_name' => 'Nguyen Duc Hoang',
'age' => 43,
'email' => 'sunlight4d@gmail.com'
],
[
'full_name' => 'John Dang',
'age' => 18,
'email' => 'john@gmail.com'
],
[
'full_name' => 'Kelly',
'age' => 40,
'email' => 'kelly123@gmail.com'
]
];
//print_r($persons);
//echo $persons[2]['email'];
var_dump(json_encode($persons));
?>