Friday, 9 August 2013

php building / populating an Array of Arrays

php building / populating an Array of Arrays

I have seen alot of tutorial on how to get the data out of a 2D array but
I need to build one similar to this and I have not found any logic I can
follow:
$array = array("socks" => array("blue", "red", "green"),
"shirts" => array("small", "medium", "large"));
I cant seem to figure out the logic to even start the code....
for each clothingType // I did this
get options // I did this
for each option //I did this
add to the clothingOption Array //... help!
Im only stuck on the building of the clothingOption 2D Array
could it be someting like
foreach clothingType as $kClothes =>VClothes
get Options
for each Options as $kOptions =>$VOption
$array[$VClothes][]= $VOption
Thanks and I hope this is not too vague....

No comments:

Post a Comment