forked from assembler-institute/php-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrays.php
More file actions
33 lines (25 loc) · 782 Bytes
/
arrays.php
File metadata and controls
33 lines (25 loc) · 782 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
<?php
echo "Regular array with strings: <br>";
$arrayStrings = array("apple", "pear", "banana");
print_r($arrayStrings);
echo "<br><br>";
echo "Regular array with numbers: <br>";
$arrayNums = array(1, 2, 4.1231);
print_r($arrayNums);
echo "<br><br>";
echo "Multidimensional array: <br>";
$arrayMultiDim = array(array("Volvo", 1), array("Seat", 2), array("Porsche", 0));
print_r($arrayMultiDim);
echo "<br><br>";
echo "Length of array: <br>";
echo count($arrayStrings);
echo "<br><br>";
echo "Combination of two arrays: <br>";
print_r(array_merge($arrayStrings, $arrayNums));
echo "<br><br>";
echo "Return last element of array: <br>";
echo (end($arrayNums)) . "<br><br>";
echo "Add element to array (2, 4): <br>";
array_push($arrayStrings, 2, 4);
print_r($arrayStrings);
?>