-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patharrays.php
More file actions
54 lines (28 loc) · 702 Bytes
/
arrays.php
File metadata and controls
54 lines (28 loc) · 702 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
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/////index array
$names = ["sola", "paul", "tope", "ade"];
$arrcount = count($names);
for ($i=0; $i < $arrcount ; $i++) {
echo $names[$i]. " is a list in the array";
echo "<br>";
}
//// assocaitive array
$assocaitive = [
"name" => "sola",
"age" => 18,
"location" => "Ondo State",
];
foreach ($assocaitive as $person => $value) {
echo $person . " = " . $value . "<br>";
}
////// multi dimension array
$multi = [
["sola", "paul", "tope", "ade"],
[18, 20, 32, 40],
["Ondo State", "Lagos State", "Oyo State", "Osun State"]
];
for ($i=0; $i < 3 ; $i++) {
for ($x=0; $x < 4; $x++) {
echo $multi[$i][$x] . "<br>";
}
}