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
31 lines (24 loc) · 709 Bytes
/
arrays.php
File metadata and controls
31 lines (24 loc) · 709 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
<?php
$nombres = array("Ana", "Maria", "Lucia");
$numbers = array(1, 3.2, 5);
#multidimensional array
$cars = array (
array("Volvo",22,18),
array("BMW",15,13),
array("Saab",5,2),
array("Land Rover",17,15)
);
echo "<br><br>";
#obtain the length of an array
var_dump(count($cars));
#combination of two arrays
$result = array_combine($nombres, $numbers);
print_r($result);
echo "<br><br>";
#Execute the function that once is given an array return the last element of it
echo end($nombres);
echo "<br><br>";
#Execute the function that once is given an array add a new element to the array in question
array_push($nombres, "Olga", "Katy");
print_r($nombres);
?>