Question
Create a Web form that shows the mileage between European capitals. Use a two-dimensional associative array to store the mileage. The form should allow the
Create a Web form that shows the mileage between European capitals. Use a two-dimensional associative array to store the mileage. The form should allow the user to enter a start city and an end city. Your code should then search the two dimensional for the distance from each city. For Example: A user enters Berlin to Paris. You should return "The distance from Berlin to Paris is: 879.96 km"
Add the following code to the script section to declare an associative array of European cities and the distances between them in kilometers, and the conversion factor for kilometers to miles:
Save the document as eudistance.php.
$Distances = array ( "Berlin" => array ("Berlin" => 0, "Moscow" => 1607.99, "Paris" => 876.96, "Prague" => 280.34, "Rome" => 1181.67), "Moscow" => array("Berlin" => 1607.99, "Moscow" => 0, "Paris" => 2484.92, "Prague" => 1664.04, "Rome" => 2374.26), "Paris" => array ("Berlin" => 876.96, "Moscow" => 641.31, "Paris" => 0, "Prague" => 885.38, "Rome" => 1105.76), "Prague" => array ("Berlin" => 280.34, "Moscow" => 1664.04, "Paris" => 885.38, "Prague" => 0, "Rome" => 922), "Rome" => array("Berlin" => 1181.67, "Moscow" => 2374.26, "Paris" => 1105.76, "Prague" => 922, "Rome" => 0)); $KMtoMiles = 0.62Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started