Question
< < PHP >> Instructions Create a new PHP Project with your name as part of the project name (eg. smith6). Create three PHP programs
<< PHP >>
Instructions
Create a new PHP Project with your name as part of the project name (eg. smith6). Create three PHP programs as follows:
PART 1
Create an associative array for 5 or 6 members of Trump's cabinet. Use positions as keys and names as values. See Example Output. Then:
- sort the array in ascending order by values and use a foreach loop to display the keys and values of the sorted array.
- sort again in ascending order by keys. Use another foreach loop to display the sorted array.
Example Output Trump Administration Cabinet Members Sorted ascending by name
- defense is Mattis
- vice is Pence
- commerce is Ross
- sec_state is Tillerson
- pres is Trump
Sorted ascending by position
- commerce is Ross
- defense is Mattis
- pres is Trump
- sec_state is Tillerson
- vice is Pence
PART 2
- Create an empty array.
- Use a for loop to add 25 random integers (all from 1-10) to the array.
- sort the array and use a foreach loop to output all elements on one line separated by spaces.
- Use an array function to display the total of all 25 elements.
- Use another array function to assign the frequency of occurrence of each value in the array to a new array.
- Use a foreach loop to display the keys and values in this latter array. See Example Output.
Example Output 1 1 1 2 2 2 3 3 3 3 3 4 4 5 5 5 6 7 7 7 7 8 9 9 10 Total of all elements = 117 1 occurred 3 times 2 occurred 3 times 3 occurred 5 times 4 occurred 2 times 5 occurred 3 times 6 occurred 1 times 7 occurred 4 times 8 occurred 1 times 9 occurred 2 times 10 occurred 1 times
PART 3
Create a 2D associative array for three NFL team partial rosters. Start with this partial roster for the Buccaneers: $nfl['Bucs'] = array('QB' => 'Winston','DT' => 'McCoy','RB' => 'Martin', 'WR' => 'Evans'); Add two more teams of your choice with players of your choice (you can look them up or make them up). Then use two foreach loops (one nested) to display the team names and rosters. See Example Output. Example Output Some NFL team players
Bucs
QB: Winston DT: McCoy RB: Martin WR: Evans
Pats
QB: Brady RB: Blount LB: Hightower
Fish
RB: Miller WR: Landry SS: Jones K: Franks
Step 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