Q,PLEASE DO THE TASK 2 BELOW <!DOCTYPE html> <html> <head> <title> PHP Arrays, S
ID: 3590993 • Letter: Q
Question
Q,PLEASE DO THE TASK 2 BELOW
<!DOCTYPE html>
<html>
<head>
<title> PHP Arrays, Strings, and File </title>
<meta charset="utf-8">
<link rel="stylesheet" href="Lab4.css" type="text/css">
</head>
<body>
<?php
ini_set('display_errors', 1); # only need to call these functions
error_reporting(E_ALL); # one time
?>
<h1> Lab 4 </h1>
<h1> <span> lab </span> </h1>
<hr>
<!-- TASK 1 -- Write your PHP code in in the space provided below. -->
<div class="task">
<h2> Task 1: While loop </h2>
<p> Simulate multiple dice rolls until a 6 is reached. Print out the results of each roll. </p>
<div class="output">
<?php
$dice = 5;
while($dice != 6) {
$dice = mt_rand(1, 6);
print("rolled $dice <br /> ");
}
?>
</div>
</div>
<!-- TASK 2 -- Write your PHP code in in the space provided below. -->
<div class="task">
<h2> Task 2: Array, for-loop, string function </h2>
<p> Create an array of strings that is made up of 10 words with the first letter capitalized.
Your strings can be of any words you want. Print out these words in a table, where the first
column is the word in the array and the second column are the same words in all uppercase. You should use a
the rows of the table. </p>
<div class="output">
<?php
/* Task 2: Put your code here */
$list = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Deaner");
?>
</div>
</div>
Explanation / Answer
$list = array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Deaner");
print('<table>');
foreach($list as $item) {
$upper = strtoupper($item);
print("<tr><th>$item</th><th>$upper</th></tr>");
}
Sample output
One ONE Two TWO Three THREE Four FOUR Five FIVE Six SIX Seven SEVEN Eight EIGHT Nine NINE Deaner DEANERRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.