How can PHP be used to sort and organize arrays of goal minutes for different teams in a soccer match?

To sort and organize arrays of goal minutes for different teams in a soccer match using PHP, you can use the array_multisort() function to sort the arrays in ascending order. You can also use array_combine() to combine the team names with their corresponding goal minutes. Finally, you can use a loop to iterate through the sorted arrays and display the results.

// Sample arrays of goal minutes for different teams
$teamA_goals = [10, 25, 40];
$teamB_goals = [5, 30, 55];

// Combine team names with their goal minutes
$teams = ['Team A', 'Team B'];
$combined_goals = array_combine($teams, [$teamA_goals, $teamB_goals]);

// Sort the goal minutes in ascending order
foreach ($combined_goals as &$goals) {
    array_multisort($goals);
}

// Display the sorted goal minutes for each team
foreach ($combined_goals as $team => $goals) {
    echo $team . " goals: " . implode(', ', $goals) . "\n";
}