【发布时间】:2010-11-29 06:34:11
【问题描述】:
我知道有很多答案,但我似乎无法正确回答。我有以下数组和我尝试过的:
$a = array ( 0 => '1421' , 1 => '2241' );
$b = array ( 0 => 'teststring1' , 1 => 'teststring2' );
$c = array ( 0 => 'teststring3' , 1 => 'teststring4' );
$d = array ( 0 => 'teststring5' , 1 => 'teststring6' );
$e = array_combine($a, array($b,$c,$d) );
但是这样我得到了错误array_combine() [function.array-combine]: Both parameters should have an equal number of elements。
我知道这是因为$a 的数组值不是键。这就是为什么我来这里看看是否可以得到一些帮助,以帮助我使它看起来像这样:
array(2) {
[1421]=>array( [0] => teststring1
[1] => teststring3
[2] => teststring5
)
[2241]=>array( [0] => teststring2
[1] => teststring4
[2] => teststring6
)
}
【问题讨论】:
标签: php arrays multidimensional-array