I have the following code:
$a = array();
$b = array('a', 'b');
for($i=0; $i<3; $i++){
$a[] = array($b[$i] => array(1, 2, 3));
}
print_r($a);
I get the following result:
Array
(
[0] => Array
(
[a] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
[1] => Array
(
[b] => Array
(
[0] => 1
[1] => 2
[1] => 3
)
)
)
This is what I'm trying to accomplish:
array (
'a' => array ( 1, 2, 3 )
'b' => array ( 1, 2, 3 )
)
What am I doing wrong? I don't want $a to add numeric elements, but rather contain a, b, c as the indexes. Any suggestions? Thanks