hi to all stackoverflow members, please help me with my problem regarding array manipulation.
stores_array:
Array
(
[0] => store1
[1] =>store2
)
items_array:
Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
here is what i have so far:
$new_array = array();
foreach($stores_array as $t) {
$new_array[$t] = $items_array;
}
echo '<pre>';
print_r($new_array);
echo '<pre/>';
here is the output:
Array
(
[store1] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
[store2] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
)
here is what i want to achieve:
i wanted to add some other values in each of the array.
pls see the arrow i intend to add.
Array
(
[store1] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
[store]=>store1 <------- how can i add these?
)
[store2] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
[store]=>store2 <------- how can i add these?
)
)
thanks you all in advance..
Try this: