I need to compare 2 arrays: Array_A and Array_B. I then want to assign to Array_A the values found in Array_B (without deleting what's already in Array_A) IF and ONLY IF the values found in Array_B are not already in Array_A.
In my mind, I'm thinking I need to use 2 FOREACH loops, but then I came across array_dif() and in_array()...
Advice is appreciated... Which approach should I use?
$finalArray = array_merge($array1, array_diff($array1, $array2));
This topic is now closed. New replies are no longer allowed.