这是我的第一个数组
Array
(
[0] => Array
(
[0] => 1
[1] => Elite
[2] => Air-Con Bus
[3] => Monday
)
[1] => Array
(
[0] => 4
[1] => KBZ
[2] => Airplane
[3] => Wednesday
)
[2] => Array
(
[0] => 5
[1] => Yoma
[2] => Cruise
[3] => Tuesday
)
)
我想成为外部数组键的内部array[0]
。像下面的数组:我可以吗?请建议我。
Array(
[1] => Array
(
[0] => 1
[1] => Elite
[2] => Air-Con Bus
[3] => Monday
)
[4] => Array
(
[0] => 4
[1] => KBZ
[2] => Airplane
[3] => Wednesday
)
[5] => Array
(
[0] => 5
[1] => Yoma
[2] => Cruise
[3] => Tuesday
)
)
答案 0 :(得分:1)
$new_array = array();
foreach ($old_array as $el) {
$new_array[$el[0]] = $el;
}
答案 1 :(得分:1)
foreach ($array as $a){
$new[$a[0]]=$a;
}