Assignment 2 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Assignment 2.php
- <?php
- //Scott Walker 5/4/2022
- //Assignment 2 - Create a contact database with name and age, then sort by name and print to screen
- echo "This is an aphabetically sorted array:";
- $database1 = array("William" => 35,
- "Nina" => 56,
- "Ted" => 73,
- "Michael" => 22,
- "Michelle" => 62
- );
- ksort($database1); //sorts the data in aphabetical order
- //Print the headers of the Table
- echo "<table border='1' cellpadding='5'>";
- echo "<tr><th>Name</th><th>Age</th></tr>";
- foreach($database1 as $Name=>$Age)
- {
- echo "<tr><td>$Name</td><td>$Age</td></tr>"; //Printes values into table cell
- }
- //Close the table
- echo "</table>";
- ?>
File Description
- Assignment 2
- PHP Code
- 04 May-2022
- 614 Bytes
You can Share it:
Latest PHP Pastes