PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
xxroniss
Forum Newbie
Posts: 3 Joined: Tue Dec 15, 2009 5:37 pm
Location: Athens,Greece
Post
by xxroniss » Wed Dec 16, 2009 2:31 am
Hello
How can i construct an array like
Code: Select all
$array[$array1][$array2][$array3]=>value
with foreach statements?
thanks
Christopher
Site Administrator
Posts: 13596 Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US
Post
by Christopher » Wed Dec 16, 2009 2:43 am
Code: Select all
foreach ($foo as $array1) {
foreach ($bar as $array2) {
foreach ($baz as $array3) {
$array[$array1][$array2][$array3] = 'value';
}
}
}
(#10850)
xxroniss
Forum Newbie
Posts: 3 Joined: Tue Dec 15, 2009 5:37 pm
Location: Athens,Greece
Post
by xxroniss » Wed Dec 16, 2009 5:52 am
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
pickle
Briney Mod
Posts: 6445 Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:
Post
by pickle » Wed Dec 16, 2009 10:27 am
If you don't understand how arrays work - spend some time with Google looking for tutorials.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
aravona
Forum Contributor
Posts: 347 Joined: Sat Jun 13, 2009 3:59 pm
Location: England
Post
by aravona » Wed Dec 16, 2009 10:30 am
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)