i have multi array and the count for all arrays is equal , the problem that i want to loop by the index , like to start with the index 0 in the first array fiscal_year then go to the second array revenue with index 0 after finish,start again to loop for the index 1 for
it will be like rows,and every row will be like this
1996-12 | 101.2
1997-12 | 249.801
array(15) {
["fiscal_year"]=>
array(21) {
[0]=>
string(7) "1996-12"
[1]=>
string(7) "1997-12"
[2]=>
string(7) "1998-12"
[3]=>
string(7) "1999-12"
[4]=>
string(7) "2000-12"
[5]=>
string(7) "2001-12"
[6]=>
string(7) "2002-12"
[7]=>
string(7) "2003-12"
[8]=>
string(7) "2004-12"
[9]=>
string(7) "2005-12"
[10]=>
string(7) "2006-12"
[11]=>
string(7) "2007-12"
[12]=>
string(7) "2008-12"
[13]=>
string(7) "2009-12"
[14]=>
string(7) "2010-12"
[15]=>
string(7) "2011-12"
[16]=>
string(7) "2012-12"
[17]=>
string(7) "2013-12"
[18]=>
string(7) "2014-12"
[19]=>
string(7) "2015-12"
[20]=>
string(3) "TTM"
}
["revenue"]=>
array(21) {
[0]=>
string(5) "101.2"
[1]=>
string(7) "249.801"
[2]=>
string(7) "493.699"
[3]=>
string(7) "548.891"
[4]=>
string(7) "543.159"
[5]=>
string(7) "536.404"
[6]=>
string(7) "474.765"
[7]=>
string(7) "509.099"
[8]=>
string(7) "588.991"
[9]=>
string(7) "643.405"
[10]=>
string(7) "732.012"
[11]=>
string(6) "808.35"
[12]=>
string(7) "777.969"
[13]=>
string(7) "758.925"
[14]=>
string(7) "773.743"
[15]=>
string(7) "652.235"
[16]=>
string(7) "650.632"
[17]=>
string(7) "667.031"
[18]=>
string(7) "636.799"
[19]=>
string(7) "594.883"
[20]=>
string(7) "594.883"
}
my code is like this and it is not work good,it is insert the first row and stop
for ($x = 0; $x <= count($company_data['fiscal_year']); $x++) {
foreach ($company_data as $key => $value) {
foreach($value as $key2 => $value2){
$this->db->set('company_name', $this->input->post('company_name'));
$this->db->set('company_code', $this->input->post('company_code'));
$this->db->set('company_hide', 1);
$this->db->set('company_created', time());
$this->db->set($key,$value2);
break;
}
}
$this->db->insert('d_company');
}