I need construct an array like this:
$data = array(
array(1 => array("<span class=\"spanBig\">A</span> ROW GREENS", array(
"A1" => "http://flexslider.woothemes.com/images/kitchen_adventurer_caramel.jpg",
"A2" => "http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg",
"A3" => "http://flexslider.woothemes.com/images/kitchen_adventurer_lemon.jpg"
))),
array(2 => array("<span class=\"spanBig\">B</span> ROW BLUE",array(
"B1" => "http://flexslider.woothemes.com/images/kitchen_adventurer_donut.jpg",
"B2" => "http://flexslider.woothemes.com/images/kitchen_adventurer_caramel.jpg",
"B3" => "http://flexslider.woothemes.com/images/kitchen_adventurer_cheesecake_brownie.jpg"
))));
Ok,I have manually this inital array:
$data = array(
array(3 => array("<span class=\"spanBig\">A</span> ROW GREENS", array())),
array(4 => array("<span class=\"spanBig\">B</span> ROW LIGHTS", array())),
array(5 => array("<span class=\"spanBig\">C</span> ROW GOLD/BROWN", array())),
array(6 => array("<span class=\"spanBig\">D</span> ROW GOLD/BROWN", array())),
array(7 => array("<span class=\"spanBig\">E</span> ROW DARK", array())),
array(2 => array("<span class=\"spanBig\">F</span> ROW DEALS", array())),
array(8 => array("<span class=\"spanBig\">M</span> ROW MARBLE", array())),
array(1 => array("<span class=\"spanBig\">OF</span> ROW LEATHER", array()))//array() is the marker
);
This have more elements but this isn't important now. Same structure but final array of each element is empty.
I create a for loop that retrieve the list of elements from each category , save them in an array and finally save it in the initial empty array, like this:
foreach($data as $dat){
foreach($dat as $key=>$da){
$_id = $key;
$sql = "SELECT l.name, p.bigimage
FROM `LocationsCategory` lc,
`NEProducts` p,
`LocationsCategoryJoin` lcj, `Locations` l
WHERE lcj.LocationsID = p.location
and p.location is not null
and l.LocationsID = lcj.LocationsID
and p.status = 1
and lcj.LocationsCategoryID = " . $_id;
$result = mysql_query($sql) or die ("ERROR");
$resultList = array();
while ($row = mysql_fetch_assoc($result)) {
//I will adding each key value pair here
$resultList[$row["name"]] = $row["bigimage"];
}
//I will save new constructed array in the marker**
$da[1] = $resultList;
}
}
I am having initial array (not desired array) again, Why I can't save my resultList in the desired position? I know that da[1] a local array from the for. I was trying some combitaions with $data but I only broke the array. Any help?