I have a problem, namely, I do not know how to put new data into my array using the array_push() function in the foreach loop (to read database data). Code:
$result = array();
$i = 0;
#$rows - data from the database
foreach($res as $rows){
$result[$i] = ['aa' => 'bb', 'cc' => 'dd', 'ee' => 'ff'];
array_push($result[$i], ['gg' => 'hh', 'ii' => 'jj']);
$i++;
}
#The expected result:
#Array('aa' => 'bb', 'cc' => 'dd', 'ee' => 'ff', 'gg' => 'hh', 'ii' => 'jj');
#Reality:
#Array(0 => ['gg' => 'hh', 'ii' => 'jj'], 'aa' => 'bb', 'cc' => 'dd', 'ee' => 'ff');
Thank you in advance for help.