I need help with creating associative arrays using input submitted by a user via an HTML drop-down list.
Here is the program requirements if this will help:
travelCosts.html allows the user to select a destination in order to find out the air fare and nightly hotel cost. Create two associative arrays named $airFare and $hotel. The $airFare array should contain the five destinations as keys (Barcelona, Cairo, Rome, Santiago, Tokyo), and the fares for these destinations as values (875.00, 950.00, 875.00, 8920.00, 1575.00). The $hotel array should contain the same five destinations as keys and the nightly rates for these destinations as values (85.00, 98.00, 110.00, 85.00, 240.00). Use the variable that contains the destination b[/b] submitted by the user to look up the appropriate air fare (to be stored in variable $farePerPerson) and the hotel rate (to be stored in variable $hotelPerNight) from these two arrays, so that these will be displayed as output statements.
Here is my HTML and PHP code so far:
travelCosts.html
TRAVEL COSTSTRAVEL COSTS
Select your travel destination: BarcelonaCairoRome</optionSantiago Tokyoyo
travelCosts.php:
TRAVEL COSTS <?php $destination = $_POST['destination']; $airFare = ; $hotel = ; $farePerPerson = ; $hotelPerNight= ; print ("TRAVEL COSTS for $destination
"); print ("The air fare is $".number_format($farePerPerson, 2)." per person
"); print ("The hotel rates are $".number_format($hotelPerNight, 2)." per night.
"); ?>I need to know how to write the two associative arrays $airFare and $hotel and then plug them into $farePerPerson and $hotelPerNight so that the print statements will work
So if the user chooses Rome, the $airFare is 875.00 and the $hotel is 85.00. So I need the output to be:
Travel Costs for Rome
The air fare is $875.00 per person.
The hotel rates are $85.00 per night.
Thanks,
Jason