Create a php file for this task. Depending on whether "Top Scorers" or "Leaders" has been clicked, you need to display the top 10 teams sorted by their total scores or total points earned. You have to read the whole CSV file when calculating total scores and total points. Top Scorers Display a table with two columns: Team and Scores. The team that has the highest number of scores is displayed first. You have to display the top 10 teams only. Note: in the CSV file, for the first row, you will see something like Arsenal FC,4-3,Leicester City FC that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3. This rule applies to all other rows as well. For this "Top Scorers" display, you need to calculate the total score of every team and then display the top 10 teams. Leaders Display a table with two columns: Team and Points. The team that has the highest number of points is displayed first. You have to display the top 10 teams only. Note: in the CSV file, for the first row, you will see something like Arsenal FC,4-3,Leicester City FC that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3, so Arsenal FC wins this match. For a match, the winner earns 3 points, the loser earns zero points. If the match is a draw, both teams earn 1 point. This rule applies to all other rows as well. For this "Leaders" display, you need to calculate the total point of every team and then display the top 10 teams. https://raw.githubusercontent.com/TriDang/cosc2430-2022-s2/main/data/football.csv Hint 1: maintain an associative array like this [ 'team 1 name' => ['scores' => calculated_score, 'points' => 'calculated points'], 'team 2 name' => ['scores' => calculated_score, 'points' => 'calculated points'], 'team 3 name' => ['scores' => calculated_score, 'points' => 'calculated points'] ] In other words, use team names as the keys for the array. The value of each key is itself another array Hint 2: loop through the CSV file If the team name has not existed yet => add a new array element and assign calculated scores and calculated points as zeros. Extract the FT column to get the score of each team. Add the score to each team Based on the score of each team, determine the winner, loser, or drawer. Add appropriate points to each team Hint 3: now you have an array of teams with all the needed information, just create 2 comparison functions and use the sort function to sort the teams. Hint 4: use fgetcsv() to read each row; use explode() to extract the score of each team.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

Create a php file for this task. Depending on whether "Top Scorers" or "Leaders" has been clicked, you need to display the top 10 teams sorted by their total scores or total points earned. You have to read the whole CSV file when calculating total scores and total points.

Top Scorers

Display a table with two columns: Team and Scores. The team that has the highest number of scores is displayed first. You have to display the top 10 teams only.

Note: in the CSV file, for the first row, you will see something like

Arsenal FC,4-3,Leicester City FC

that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3. This rule applies to all other rows as well. For this "Top Scorers" display, you need to calculate the total score of every team and then display the top 10 teams.

Leaders

Display a table with two columns: Team and Points. The team that has the highest number of points is displayed first. You have to display the top 10 teams only.

Note: in the CSV file, for the first row, you will see something like

Arsenal FC,4-3,Leicester City FC

that means for this particular match, Arsenal FC scored 4 and Leicester City FC scored 3, so Arsenal FC wins this match. For a match, the winner earns 3 points, the loser earns zero points. If the match is a draw, both teams earn 1 point. This rule applies to all other rows as well. For this "Leaders" display, you need to calculate the total point of every team and then display the top 10 teams.

https://raw.githubusercontent.com/TriDang/cosc2430-2022-s2/main/data/football.csv

Hint 1: maintain an associative array like this

[

'team 1 name' => ['scores' => calculated_score, 'points' => 'calculated points'],

'team 2 name' => ['scores' => calculated_score, 'points' => 'calculated points'],

'team 3 name' => ['scores' => calculated_score, 'points' => 'calculated points']

]

In other words, use team names as the keys for the array. The value of each key is itself another array

Hint 2: loop through the CSV file

If the team name has not existed yet => add a new array element and assign calculated scores and calculated points as zeros.

Extract the FT column to get the score of each team. Add the score to each team

Based on the score of each team, determine the winner, loser, or drawer. Add appropriate points to each team

Hint 3: now you have an array of teams with all the needed information, just create 2 comparison functions and use the sort function to sort the teams.

Hint 4: use fgetcsv() to read each row; use explode() to extract the score of each team.

Expert Solution
steps

Step by step

Solved in 5 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education