PHP 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...


PHP


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:


I$Distances = array (<br>
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.62; "/>
Extracted text: I$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.62;
Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here