【发布时间】:2013-11-13 07:52:01
【问题描述】:
我有两个数组。带有足球运动员位置的数组 A 和带有足球运动员的数组 B。 每个玩家都有一个名字和一个位置。
现在我想将数组 B 拆分到数组 A 的不同位置,然后将其重新排序到一个数组中,该数组的排序类似于数组 A 中的位置。
数组如下所示:
数组 A 数组 ( tor, 阿布维尔, 米特尔费尔德, 猛击)
数组 B 阵列(阵列(洛基,风暴), 数组(Kevin,Abwehr))
我的结果数组应该是这样的:
Array ( tor,
abwehr(Array ( Kevin, Abwehr )),
mittelfeld,
sturm(Array ( Rocky, Sturm )) )
到目前为止我的代码:
$positionen = array("tor", "abwehr", "mittelfeld", "sturm");
foreach($positionen as $position) {
$team = $extern_source->api();
foreach($team['data'] as $team) {
//need to explode this to filter relevant infos
$team_info = explode("\n",$team['info']);
$sp_name=$team_info[1];
$sp_posi=$team_info[4];
//put together the single infos in a new array
...
我真的希望你能理解我的问题。 它在我的脑海里打了个结。好复杂:D
非常感谢! 来自德国的问候。
【问题讨论】:
标签: php arrays multidimensional-array foreach explode