Hi;
I'm getting more serious about getting skilled with use of arrays. Here's something I'm not clear on:
Say I've established a couple of arrays:
$arr_1 = array("foo" => "bar", 12 => true);
$arr_2 = array("First item", 2, "Third item");
THEN I combine them into a two-dimensional array like so:
$m_arr = array($arr_1, $arr_2);
Up to this point everything works fine: If I echo $m_arr[1][2], I get the value "Third item" just like I expect.
Later on in the sequence of my script, say I want to add another element into $arr_1. So I do this:
$arr_1[]=("Surprise!"); //key in [] will be 13 because 12 has been used as first number/integer key
When I call to echo $m_arr[1][13] i get nothing.
In order for this to work I've found I have to:
unset ($m_arr); and then re-create it.
$m_arr = array($arr_1, $arr_2);
is this a necessary step to get the new value into the multidimensional array or is there a more direct way?
Thanks