Reputation: 105
I have two arrays
$array1 = array(33=>'abc,bcd,cde,def');
$array2 = array(33=>'fgh,ghi,hij,ijk');
How I can add two arrays to get the below result?
$array3 = array(33=>'abc,bcd,cde,def,fgh,ghi,hij,ijk');
Thanks in advance...
Upvotes: 0
Views: 698
Reputation: 3041
I presume you want to do this automatically for multiple keys. Try something like this:
$newArray = array();
foreach ($array1 as $key => $value) {
$newArray[$key] = $array1[$key] . ',' . $array2[$key];
}
Keep in mind you will need checks to see if the data is in both arrays if they do not exactly match.
Upvotes: 2