嗨,所有stackoverflow成员,请帮助我解决有关数组操作的问题。
stores_array:
Array
(
[0] => store1
[1] =>store2
)
items_array:
Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
这是我到目前为止所拥有的:
$new_array = array();
foreach($stores_array as $t) {
$new_array[$t] = $items_array;
}
echo '<pre>';
print_r($new_array);
echo '<pre/>';
这是输出:
Array
(
[store1] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
[store2] => Array
(
[electronics]=>led tv
[cosmetics]=>eyeliner
[fruits]=>apple
[vegetables]=>cabbage
)
)
这是我想要实现的目标:
我想在每个数组中添加一些其他值。
请看我打算添加的箭头。
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?
)
)
提前谢谢大家..