For this PHP coding activity, you will complete the two exercises listed below and once you have tested them, you will upload the .php file(s)
Exercise #1:
For this exercise, you will use a list of ten of the largest cities in the world. (Please note, these are not the ten largest, just a selection of ten from the largest cities.) Create an array with the following values: Tokyo, Mexico City, New York City, Mumbai, Seoul, Shanghai, Lagos, Buenos Aires, Cairo, London.
Print these values to the browser separated by commas, using a loop to iterate over the array. Sort the array, then print the values to the browser in an unordered list, again using a loop.
Add the following cities to the array: Los Angeles, Calcutta, Osaka, Beijing. Sort the array again and print it once more to the browser in an unordered list.
Name your PHP file cities.php and upload to your folder on the Synology NAS server using FileStation.
Exercise #2:
In this PHP exercise, you will create an array of temperatures. Choose a spring month to have a wider range of temperatures to handle. We’ll use 30 days of the month. The exercise is generic, but feel free to use a specific month in your own script. The answer script will use the Fahrenheit scale, but again feel free to use Celsius if you prefer.
Create your array of 30 high temperatures, approximating the weather for a spring month, then find the average high temp, the five warmest high temps and the five coolest high temps. Print your findings to the browser.
Hint: the HTML character entity for the degree sign is °.
Gather data for your own area or country for a spring month like March, April, or May. Here’s a list of thirty Fahrenheit high temperatures as an example:68, 70, 72, 58, 60, 79, 82, 73, 75, 77, 73, 58, 63, 79, 78, 68, 72, 73, 80, 79, 68, 72, 75, 77, 73, 78, 82, 85, 89, 83
Write your PHP code and name your PHP file temp_array.php and upload to your folder on the Synology NAS server using FileStation. Test the program you write.