Multidimensional array is driving me crazy
Posted: Sun Sep 12, 2004 1:08 pm
I'm trying to build a multidimensional array of products. The main array's KEY name is PRODUCTS. Within products there are RECORDS and CLOTHES. Within RECORDS there are SIZE and COLOR arrays. Within CLOTHES array, there is a TSHIRTS array. Within the TSHIRTS array, there are SIZE and COLOR arrays. My array looks like this:
But a print_r($array) shows that the array COLOR array (both inside the RECORDS and TSHIRTS arrays) are outside of the arrays which I'm intending on being their parent. Take a look:
I'm sure this is a matter of me putting a parentheses in the wrong place, but I can't figure out where for the life of me. Anyone? Help?
Code: Select all
$array = array('PRODUCTS' =>
array('RECORDS' =>
array('SIZE' => array('7INCH','10INCH','12INCH','OTHER')),
array('COLOR' => array('BLACK','WHITE','GREY'))
),
array('CLOTHES' =>
array('T-SHIRTS' =>
array('SIZE' => array('SMALL','MEDIUM','LARGE')),
array('COLOR' => array('BLACK','WHITE','GREY'))
)
)
);Code: Select all
Array
(
їPRODUCTS] => Array
(
їRECORDS] => Array
(
їSIZE] => Array
(
ї0] => 7INCH
ї1] => 10INCH
ї2] => 12INCH
ї3] => OTHER
)
)
ї0] => Array
(
їCOLOR] => Array
(
ї0] => BLACK
ї1] => WHITE
ї2] => GREY
)
)
)
ї0] => Array
(
їCLOTHES] => Array
(
їT-SHIRTS] => Array
(
їSIZE] => Array
(
ї0] => SMALL
ї1] => MEDIUM
ї2] => LARGE
)
)
ї0] => Array
(
їCOLOR] => Array
(
ї0] => BLACK
ї1] => WHITE
ї2] => GREY
)
)
)
)
)