The problem here is preserving the keys for the identifier you want. You have some names strings that have the same key (like Bl? and R?d). You either need to store these in an array or be willing to lose the key.
Example with php5.3:
$processed = array_map(function($a) { return array_pop($a); }, $arr);
This will give you:
[0] => R?d
[1] => Bl?
[2] => Bobo
[3] => Gr?n
[4] => Sten
[5] => Vit
[6] => Guld
[7] => Lyxig
It has become clear the keys on the inner array need to be preserved because they are some kind of id. With that said you must change the end structure you're going for because you can have 2 of the same key in a single array. The simplest structure then becomes:
[8] => Array
(
[0] => R?d,
[1] => Bl?,
[2] => Vit,
[3] => Gr?n
)
[6] => Array
(
[0] => Bobo,
[1] => Lyxig
)
[7] => Array
(
[0] => Sten,
[1] => Guld
)
To get this structure a simple loop will work:
$processed = array();
foreach($arr as $subarr) {
foreach($subarr as $id => $value) {
if(!isset($processed[$id])) {
$processed[$id] = array();
}
$processed[$id][] = $value;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…