PHP CODE (PLEASE USE IF ELSE) TASK 3 Task 3: Style Modification PHP is driving m
ID: 3596665 • Letter: P
Question
PHP CODE (PLEASE USE IF ELSE)
TASK 3 Task 3: Style Modification PHP is driving me crazy This task is very similar to task 2. Your task is to modify the style of the text "PHP is driving me crazy" Specifically, each time your PHP program runs, it should randomly select the color of the text to be one of three choices: red, green, or blue. It should also randomly select the font size of the text to be one of three choices: 0.5em, 1em, 3em. You should be able to determine how to do this task based on how you completed task 3. The links to the examples of the if statements at the top of the lab will help! The following shows example outputs that your code can generate: PHP Is driving me PHP is PHP is driving font-size: 1em;"> drivingExplanation / Answer
use of if - else statements is not required in the following code:
<html>
<body>
<?php
$color = array("Red","Blue","Green");
$size = array("0.5em","1em","2em");
shuffle($color);
shuffle($size);
?>
<p><span>PHP is driving me crazy</span></p>
</body>
</html>
but if it is a compulsion, then you can use this folowing code:
<html>
<body>
<?php
$color = array("Red","Blue","Green");
$size = array("0.5em","1em","2em");
$arr = array(0,1,2);
shuffle($arr);
shuffle($size);
shuffle($color);
if($arr[0]==0){
$fontcolor = $color[0];
$fontsize = $size[0];
}
else if($arr[0]==1){
$fontcolor = $color[1];
$fontsize = $size[1];
}
else{
$fontcolor = $color[2];
$fontsize = $size[2];
}
?>
<p><span>PHP is driving me crazy</span></p>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.