Array
[1] => Array ( [0] => x [1] => num1 [2] => num2 )
[2] => Array ( [0] => y [1] => num3 [2] => num4 )
[3] => Array ( [0] => z [1] => num5 [2] => num6 )
..........
我想要的是php,[0]索引值,即x,y,z ......成为索引,num1,num2 ......成为它们的值。总之,我想要一个散列,其中x,y,z ...作为索引,num1,num2(对于x)num3,num4(对于y)作为这些索引的值。应该是这样的,
Array
[x] => Array ( [0] => num1 [1] => num2 )
[y] => Array ( [0] => num3 [1] => num4 )
[z] => Array ( [0] => num5 [1] => num6 )
答案 0 :(得分:3)
类似于:
$new = Array();
foreach($original as $entry) $new[array_shift($entry)] = $entry;
(未经测试,可能是操作顺序错误,但可能很好)。