forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arrays.php
56 lines (47 loc) · 1.04 KB
/
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
<?php
// Strings
echo "<h3>Strings</h3>";
$arrStrings = ["a", "b", "c"];
var_dump($arrStrings);
echo "<br>";
// Numbers
echo "<h3>Numbers</h3>";
$arrNumbers = [3, 4.2, 1];
var_dump($arrNumbers);
echo "<br>";
// Multidimensional
echo "<h3>Multidimensional</h3>";
$arrMultidimensional = [
"Pau",
["a", "b", "c"],
[3, 4.2, 1]
];
var_dump($arrMultidimensional);
echo "<br>";
// Length
echo "<h3>Length</h3>";
$arrLength = count($arrStrings);
echo $arrLength;
echo "<br>";
// Combination
echo "<h3>Combination</h3>";
$arrCombination = array_merge($arrStrings, $arrNumbers);
print_r(array_merge($arrStrings, $arrNumbers));
echo "<br>";
var_dump($arrCombination);
echo "<br>";
// Last element of an array
echo "<h3>Last element of an array</h3>";
$arrLastElement = end($arrStrings);
echo $arrLastElement;
echo "<br>";
// New element to an array
echo "<h3>New element to an array</h3>";
$arrAddElement = array_push($arrStrings, "d", "e");
print_r($arrStrings);
echo "<br>";
var_dump($arrStrings);
echo "<br>";
echo $arrAddElement;
echo "<br>";
?>