我有2個數組:數組合並:使用foreach?
$im=explode(",", $data['products']);
$imi=explode(",", $data['period']);
其相關聯:
$data['products'] = balon,globo,sesta
$data['period'] = 1,1,2
所以當我合併的結果,它是:
Array ([0] => DS Basic [1] => DS Pro [2] => DS Start [3] => 1 [4] => 1 [5] => 2)
的問題是,我需要它是像這樣關聯:
DS Basic = 1 , DS Pro = 1 , DS Start = 2
我正在使用array_merge($im,$imi)
我該如何使用foreach
來做到這一點? 我想這樣的:
Array ([0] => DS Basic [1] => DS Pro [2] => DS Start)
Array ([0] => 1 [1] => 1 [2] => 2)
所以,當我使用它,它可以像
using foreach
DS basic has a period of 1
DS pro has a period of 1
DS start has a period of 2
你能'的print_r( $ IM)'? – aldrin27