I am takeing an PHP class and can you help me with the first assingnment? Assign
ID: 3879822 • Letter: I
Question
I am takeing an PHP class and can you help me with the first assingnment?
Assignment 1.1 Instructions In this exercise, you will create and modify a script that stores interest rates in an array. Complete the steps below: 1. Open Notepad++ and create a new document. 2. Type the <!DOCTYPE> declaration, <html> element, header information, and <body> element. Use the strict DTD and “Interest Array” as the content of the <title> element. 3. Add the following standard PHP script delimiters to the document body: <?php ?> 4. Add the following statements to the script section:
$InterestRate1 = .0725; $InterestRate2 = .0750; $InterestRate3 = .0775; $InterestRate4 = .0800; $InterestRate5 = .0825; $InterestRate6 = .0850; $InterestRate7 = .0875;
5. Using the array () construct, modify the statements you added in the preceding step so the variables are saved in an array named $RatesArray. Also, add statements to the program that display the contents of each array element. 6. Save the document as InterestArrayLastname.php (Lastname should be your last name) in the Projects directory for Chapter 1, then validate it with the W3C HTML Validator. After the document is valid, open it in your Web browser to see how it renders. Hint: URL should be http://localhost/PHP_Projects/Chapter.01/InterestArray<Lastname>.php 7. Finally, upload the file to the assignment dropbox in Blackboard.
Explanation / Answer
Save the file as specified in the question.
W3C validator doesn't throw any errors.
Code:
<!DOCTYPE html>
<html>
<head>
<title>Interest Array</title>
</head>
<body>
<?php
$InterestRate1 = .0725;
$InterestRate2 = .0750;
$InterestRate3 = .0775;
$InterestRate4 = .0800;
$InterestRate5 = .0825;
$InterestRate6 = .0850;
$InterestRate7 = .0875;
#Adding elements to the array as asked in section
$ratesArray = array($InterestRate1, $InterestRate2, $InterestRate3, $InterestRate4, $InterestRate5, $InterestRate6, $InterestRate7);
#displaying array elements
foreach($ratesArray as $rate){
echo $rate;
print("<br/>");#For new line
}
?>
</body>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.