How can I target a multi-dimensional associative array by index? I need to be able to do something along the lines of this…
$x=2;
$assoc_array = array(
"red" => array(1,2,3,4,5),
"green" => array(1,2,3,4,5),
"blue" => array(1,2,3,4,5)
);
array_push($assoc_array[$x],6);
You actually can do that. As an alternative, you can use
$assoc_array[$x][] = 6EDIT: The above is the answer for what you asked. The code below is for what I think you need, but didn’t state clearly:
Working codepad example: http://codepad.org/QXfHmKH8