我在PHP中有这个多维数组...
$team1 = Array
( [0] => Array
(
[player_num] => 87,
[team] => "penguins",
[last_name] => "crosby",
[first_name] => "sydney",
[rating] => 95,
)
[1] => Array
(
[player_num] => 13,
[team] => "red wings",
[last_name] => "datsyuk",
[first_name] => "pavel",
[rating] => 94,
)
[2] => Array
(
[player_num] => 55,
[team] => "red wings",
[last_name] => "kronwall",
[first_name] => "niklas",
[rating] => 89
)
[3] => Array
(
[player_num] => 67,
[team] => "predators",
[last_name] => "weber",
[first_name] => "shea",
[rating] => 6,
)
)
我已经使用PDO从SQLite数据库创建了这个数组。我的问题是我想要读入这个数组,然后将其分解为单个数组,这样每个播放器都是自己的数组,然后可以进一步细分并用于向我自己的播放器对象添加信息用PHP创建。 主要问题是如何使用这个多维数组并将其分解为单个数组?
到目前为止,我有这个代码只是将键与值分开...
foreach ($teamRed as $team=>$player) {
echo "$team Value:<br>";
foreach ($player as $key=>$value){
echo "$key: $value<br>";
}
echo "<br>";
}