Page 1 of 1

multidimensional arrays

Posted: Wed Dec 16, 2009 2:31 am
by xxroniss
Hello

How can i construct an array like

Code: Select all

$array[$array1][$array2][$array3]=>value
with foreach statements?


thanks

Re: multidimensional arrays

Posted: Wed Dec 16, 2009 2:43 am
by Christopher

Code: Select all

foreach ($foo as $array1) {
     foreach ($bar as $array2) {
          foreach ($baz as $array3) {
               $array[$array1][$array2][$array3] = 'value';
          }
     }
}

Re: multidimensional arrays

Posted: Wed Dec 16, 2009 5:52 am
by xxroniss
thanks for your answer

Please check this post in the code section and give me some guidelines
cause i suppose i dont really understand the array keys concept

viewtopic.php?f=1&t=110279

thnx again

Re: multidimensional arrays

Posted: Wed Dec 16, 2009 10:27 am
by pickle
If you don't understand how arrays work - spend some time with Google looking for tutorials.

Re: multidimensional arrays

Posted: Wed Dec 16, 2009 10:30 am
by aravona
http://www.w3schools.com/php/php_arrays.asp

That site helped me with university work on arrays within php - it may clarify the basics for you (theres a complete reference guide for array functions right at the end too)