jagoan-neon Posted March 29, 2009 Share Posted March 29, 2009 Hi all, I have this code : for ( $i = 0; $i < count($id_list); $i++) { $array = Array ( $i => Array('id' => "$id_list[$i]", 'traffic' => "$kunjungan_list[$i]", 'rekrut' => "$rekrut_list[$i]", 'input_data' => "$input_list[$i]", 'sms' => "$sms_list[$i]", 'poll' => "$poll_list[$i]" ), ); } When i view the result is : Array ( [389] => Array ( [id] => gempar [traffic] => 8146 [rekrut] => 273 [input_data] => 20 [sms] => 14 [poll] => 1 ) ) How to add all data? I want to have Array from 0 to 389, not 389 only Thank you very much. Link to comment https://forums.phpfreaks.com/topic/151623-solved-using-foreach-to-add-new-array/ Share on other sites More sharing options...
wildteen88 Posted March 29, 2009 Share Posted March 29, 2009 $array = array(); for ( $i = 0; $i < count($id_list); $i++) { $array[$i] = array( 'id' => $id_list[$i], 'traffic' => $kunjungan_list[$i], 'rekrut' => $rekrut_list[$i], 'input_data' => $input_list[$i], 'sms' => $sms_list[$i], 'poll' => $poll_list[$i] ); } Link to comment https://forums.phpfreaks.com/topic/151623-solved-using-foreach-to-add-new-array/#findComment-796307 Share on other sites More sharing options...
jagoan-neon Posted March 29, 2009 Author Share Posted March 29, 2009 PHPFreaks is the best! Thank you! Link to comment https://forums.phpfreaks.com/topic/151623-solved-using-foreach-to-add-new-array/#findComment-796310 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.