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
56 lines (35 loc) · 1.21 KB
/
arrays.php
File metadata and controls
56 lines (35 loc) · 1.21 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
$cities = array("Madrid", "Barcelona", "Sevilla");
print_r($cities);
echo "<br><br>";
$nums = array(2, 3.5, 5, 5.8, 9);
print_r($nums);
echo "<br><br>";
$gaming = array (
array("Ps5",16,19),
array("NSwtich",17,12),
array("XboxScorpion",4,1),
array("Wii",20,12)
);
echo $gaming[0][0].": In stock: ".$gaming[0][1].", sold: ".$gaming[0][2].".<br>";
echo $gaming[1][0].": In stock: ".$gaming[1][1].", sold: ".$gaming[1][2].".<br>";
echo $gaming[2][0].": In stock: ".$gaming[2][1].", sold: ".$gaming[2][2].".<br>";
echo $gaming[3][0].": In stock: ".$gaming[3][1].", sold: ".$gaming[3][2].".<br>";
echo "<br><br>";
$cities = array("Madrid", "Barcelona", "Sevilla");
echo count($cities);
#Concatenar arrays;
$spanishcities = array("Madrid", "Barcelona", "Sevilla");
$frenchcities = array("paris","Toulosse");
$europeancities = array_merge($spanishcities, $frenchcities);
print_r($europeancities);
echo "<br><br>";
#Coger ultimo parametro de un array;
$colors = array("red", "yellow", "blue", "pink");
echo end($colors);
echo "<br><br>";
#Introducir un nuevo parametro en un array;
$colors = array("red", "yellow", "blue", "pink");
array_push($colors, "brown", "black");
print_r($colors);
?>