-
Notifications
You must be signed in to change notification settings - Fork 3
/
array-practice.php
64 lines (46 loc) · 1.21 KB
/
array-practice.php
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
57
58
59
60
61
62
63
64
<?php
// Turn on error reporting
ini_set('display_errors', 1);
error_reporting(E_ALL);
echo "<pre>";
echo "Indexed arrays:<br>";
$movies = array("Back to the Future", "Brave Heart", "Tron Legacy", "The Bodyguard");
$movies[] = "Wonder Woman";
var_dump($movies);
$shows[] = "Scrubs";
$shows[] = "The Boys";
$shows[] = "Mr. Robot";
var_dump($shows);
$bands = array();
$bands[] = "U2";
echo "<ul>";
foreach($movies as $movie) {
echo "<li>$movie</li>";
}
echo "</ul>";
echo "<ol>";
foreach($shows as $show) {
echo "<li>$show</li>";
}
echo "</ol>";
echo "Associative arrays:<br>";
$classes = array("SDEV 305"=>"Web Dev",
"SDEV 301"=>"Systems",
"SDEV 378"=>"Career Prep");
var_dump($classes);
echo "<p>{$classes['SDEV 305']}</p>";
echo "<ul>";
foreach($classes as $courseNum=>$courseTitle) {
echo "<li>$courseNum -> $courseTitle</li>";
}
echo "</ul>";
$colors = array("Aaron"=>"green", "Joseph"=>"olive");
$colors['Sarah'] = 'blue';
$colors['Kim'] = 'pink';
$colors['Alisa'] = 'mint green';
var_dump($colors);
foreach ($colors as $person=>$color) {
echo "<p>$person likes $color</p>";
}
var_dump($_SERVER);
echo "</pre>";