-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrayobjects.php
56 lines (40 loc) · 1.2 KB
/
arrayobjects.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
<?php
// exercise 1 (Create a non-associative array with 3 integer values and display the total sum of them.)
$integers = [
"first" => 5,
"second" => 7,
"third" => 10
];
echo $integers["first"] + $integers["second"] + $integers["third"] . PHP_EOL;
// exercise 2 (Using dump method, dump out all 3 values.)
$person = [
"name" => "John",
"surname" => "Doe",
"age" => 50
];
var_dump($person) . PHP_EOL;
// exercise 3 (Using dump method, dump out all 3 values.)
$person = new stdClass();
$person->name = "John";
$person->surname = "Doe";
$person->age = 50;
var_dump($person) . PHP_EOL;
// exercise 4 (Program should display concatenated value of - Jane Doe 41)
$items = [
[
[
"name" => "John",
"surname" => "Doe",
"age" => 50
],
[
"name" => "Jane",
"surname" => "Doe",
"age" => 41
]
]
];
echo $items[0][1]["name"] . ' ' . $items[0][1]["surname"] . ' ' . $items[0][1]["age"] . PHP_EOL;
// exercise 5 (Program should display concatenated value of - John & Jane Doe`s)
echo $items[0][0]["name"] . ' & ' . $items[0][1]["name"] . ' ' . $items[0][1]["surname"] . '´s' . PHP_EOL;
?>