I am trying to add two arrays $arraydata1
and $arraydata2
to get the array $result
. But it shows the result as if $result=$arraydata1;
, not as
$result=$arraydata1+$arraydata2;
.
Here is the array I am trying to add after getting it from the CSV file and storing it in different array type variable.
$result = array();
$arraydata1 = array();
$arraydata2 = array();
$key1 = array("itemid","itembrand","itemname","itemmodel","itemdesc","itemtype","itemprice","itemimgfolder","itemimage");
$key2 = array("itemid","itembrand","itemname","itemmodel","itemdesc","itemtype","itemprice","itemimgfolder","itemimage");
foreach (file('data/dell/data.csv') as $key => $str)
{
if ($key == 0) continue; // to skip headings of the csv file
$values = str_getcsv($str, "\t", '', '');
$arraydata1[] = array_combine($key1, $values);
} // to store first array data
foreach (file('data/hp/data.csv') as $key => $str)
{
if ($key == 0) continue; // to skip headings of the csv file
$values = str_getcsv($str, "\t", '', '');
$arraydata2[] = array_combine($key2, $values);
}
$result = $arraydata2+$arraydata2; // result the combination of the two arrays
Everything else is working fine. I have also tried array_combine()
but it did not work either.