103 lines
1.8 KiB
PHP
103 lines
1.8 KiB
PHP
<!DOCTYPE html>
|
|
<html>
|
|
|
|
<head>
|
|
<title>PHP Lab 7</title>
|
|
<meta charset="utf-8">
|
|
</head>
|
|
|
|
<body>
|
|
<h1>Months of the Year</h1>
|
|
<?php
|
|
$months = [
|
|
1 => "January",
|
|
"February",
|
|
"March",
|
|
"April",
|
|
"May",
|
|
"June",
|
|
"July",
|
|
"August",
|
|
"September",
|
|
"October",
|
|
"November",
|
|
"December"
|
|
];
|
|
|
|
print_r($months);
|
|
|
|
echo "<br><br>";
|
|
|
|
$months[13] = "Winter";
|
|
$months[14] = "Construction";
|
|
|
|
foreach ($months as $type => $value) {
|
|
echo "The month of $value is month number $type<br>";
|
|
}
|
|
?>
|
|
|
|
<h1>Pizza Toppings</h1>
|
|
|
|
<?php
|
|
$vegetables = [
|
|
"Green Peppers",
|
|
"Mushrooms",
|
|
"Olives",
|
|
"Chives"
|
|
];
|
|
$meats = [
|
|
"Pepperoni",
|
|
"Ham",
|
|
"Bacon"
|
|
];
|
|
$cheeses = [
|
|
"Mozzarella",
|
|
"Cheddar",
|
|
"Provologne"
|
|
];
|
|
|
|
$toppings = [
|
|
"Vegetables" => $vegetables,
|
|
"Meats" => $meats,
|
|
"Cheeses" => $cheeses
|
|
];
|
|
|
|
foreach ($toppings as $type => $value) {
|
|
echo "$type: ";
|
|
if (is_array($value)) {
|
|
foreach ($value as $number => $topping) {
|
|
echo "$topping, ";
|
|
}
|
|
} else {
|
|
echo "$type is $value<br>";
|
|
}
|
|
echo "<br>";
|
|
};
|
|
|
|
echo "<br>";
|
|
|
|
$prices = [
|
|
"Small" => 6.99,
|
|
"Medium" => 8.99,
|
|
"Large" => 13.99,
|
|
"X-Large" => 18.99,
|
|
"Supersize" => 22.99
|
|
];
|
|
|
|
asort($prices);
|
|
|
|
foreach ($prices as $type => $value) {
|
|
echo "$type: $value<br>";
|
|
};
|
|
|
|
echo "<br>";
|
|
|
|
ksort($prices);
|
|
|
|
foreach ($prices as $type => $value) {
|
|
echo "$type: $value<br>";
|
|
};
|
|
?>
|
|
</body>
|
|
|
|
</html>
|