>Hi All > >I want to create a multi dimensional arrays as below > >$result[$something]['$key_string_01] = value_01 >$result[$something]['$key_string_02] = value_02 >$result[$something]['$key_string_03] = value_03 >$result[$something]['$key_string_04] = value_04 >$result[$something][0] = value_06 >$result[$something][1] = value_07 >$result[$something][2] = value_08 >. >. >. > >Here is what I did >1. use some assign statement $result[$something]['$key_string_0n'] = >value_0n for the first four elements >2. for the fifth elements onward, I used this >$result[$something] = preg_split(....); > >However, as I test it with foreach loop, I am only getting > >$result[$something][0] = value_06 >$result[$something][1] = value_07 >$result[$something][2] = value_08 >. >. >. > >I lost the first four elements!! Can anyone help on this please?
What you are doing seems pretty weird to me... Did you do reset($result) before you looped through the values to display them? If not, it *could* be the case that the assignment with the preg is somehow mis-managing the iteration pointer. This seems highly unlikely, but it's the cheapest and easiest answer I have for you. Just for fun, try using $result[$something][] = preg_split(...); and see what it does... Finally, if all else fails, it's really not worth beating your head against a wall on this: $result1[...][...] = 01; $result1[...][...] = 02; $result1[...][...] = 03; $result1[...][...] = 04; $result2[...] = preg_split(...); $result = array_merge($result1, $result2); http://php.net/array_merge It might still be a bug worth reporting, but it ain't worth waiting for the PHP Dev team to fix it when you can move on to bigger problems :-) Actually, I'm not sure it's a bug at all... The semantics of what an assignment should mean in a situation like this are not at all clear... Somebody else could be equally disconcerted that their "old" values are *NOT* getting wiped out when they do the assignments like that. I believe that unless you are assigning a SINGLE element into an array, this issue would be germane. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php