Lab 4 Working With Arrays
Lab 4 Working With Arrays
• Close all the opening file in the PHP Editor view by right click to a file and choose Close All.
Step 2. Right click on LabProject, choose New Folder. Enter Lab4 as folder name.
From now, put all files in this lab to Lab4 folder.
4.2. Tuna Café
Step 1. TunaCafe.php
Step 2. TunaResults.php
Step 3. Run
4.3. Drive Distance
Step 1. DriveDistance.php
Step 2. CheckDistance.php
Step 3. Run
Step 4. Note that although the user selects 3 destination, the result only calculate
for the last destination. Modify CheckDistance.php to calculate and
display information for all destinations, each destination is located in a
row of a table (the table has 5 columns: No., Destination, Distance, Driving
time (60 mph), Walking time (5 mph)).
<?php
if($submitted) {
if($sort_type == 'usort' || $sort_type == 'uksort' || $sort_type == 'uasort') {
$sort_type($values, 'user_sort');
}
else {
$sort_type($values);
}
}
?>
<p align="center">
<input type="submit" value="Sort" name="submitted" />
</p>
<p>
Values <?= $submitted ? "sorted by $sort_type" : "unsorted"; ?>:
</p>
<ul>
<?php
foreach($values as $key=>$value) {
echo "<li><b>$key</b>: $value</li>";
}
?>
</ul>
</form>
Modify to run it in one PHP file allowing users to sort the data as they choose in the radio button.