Write a program that defines a multidimensional array $clubs that stores information about four football clubs, including the name, and the year founded. The program should print the contents of the array using a foreach loop. The program should also sort the array by the club name using the sort() function. Finally, it should print the sorted array. Complete the code:
Write a program that defines a multidimensional array $clubs that stores information about four football clubs, including the name, and the year founded. The program should print the contents of the array using a foreach loop. The program should also sort the array by the club name using the sort() function. Finally, it should print the sorted array.
Complete the code:
<?php
// Define a multidimensional array
$clubs = array(
array("Newcastle United","England", 1892),
array("Gezira Sporting Club", "Egypt", 1882),
array("Zamalek Sporting Club", "Egypt", 1911),
array("Bidvest Wits South Africa", "Egypt", 1921)
);
// Print the contents of the array
echo "List of football clubs:\n";
foreach ( //Add code) {
//Add code
}
// Sort the array by the first column
sort(//Add code);
// Print the sorted array
print_r(//Add code);
?>
Step by step
Solved in 3 steps with 2 images