我试图理解多维关联数组。我需要一个使用关联数组的信息列表,并用
foreach()
回路。
列表如下:
我得到了一个包含所有信息的关联数组
$spellen = array(
"Game1" => array (
"Amount of players" => "10 to 20",
"Age" => "8+",
"Price" => "â¬24,99"
),
"Game2" => array (
"Amount of players" => "2 to 24",
"Age" => "12+",
"Price" => "â¬34,99"
),
"Game3" => array (
"Amount of players" => "6 to 24",
"Age" => "6+",
"Price" => "â¬45,99"
),
);
但是我如何使用
foreach()。
循环,这样我的最终结果将如下所示:
Game 1 can be played with 10 to 20 players, The minimal age is 8+ and the game has a price of 24,99
Game 2 can be played with 2 to 24 players, The minimal age is 12+ and the game has a price of 34,99
Game 3 can be played with 6 to 8 players, The minimal age is 6+ and the game has a price of 45,99
Game 2 costs 24,99
The game that costs 45,99 is called Game 3