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
36 lines (28 loc) · 1.03 KB
/
arrays.php
File metadata and controls
36 lines (28 loc) · 1.03 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
<?php
// Define a simple array composed of text strings
$stringArray = array("the","world","of","php");
print_r($stringArray);
echo "<br>";
// Define a simple array consisting of whole numbers and decimal numbers
$numberArray = array(1,2.2, 3,4.5,5);
print_r($numberArray);
echo "<br>";
// Define a multidimensional array
$multiDimArray = array (array(4,5,6), array(1,2,3));
print_r($multiDimArray);
echo "<br>";
// Execute the function that allows to obtain the length of an array
$array_l = count($stringArray);
echo $array_l."<br>";
// Execute the function that allows to obtain the combination of two arrays
$array_merge = array_merge($stringArray, $numberArray);
print_r($array_merge);
echo "<br>";
// Execute the function that once is given an array return the last element of it
$lastElement = array_key_last($stringArray);
print_r($stringArray[$lastElement]);
echo "<br>";
// Execute the function that once is given an array add a new element to the array in question
array_push($stringArray, "v8");
print_r($stringArray);
echo "<br>";