Results 1 to 2 of 2
Apr 4, 2013, 10:46 #1
Comparing 2 arrays IF and ONLY IF Array_A doesn't have values found in Array_B?
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?
Apr 4, 2013, 10:51 #2
- Join Date
- Jun 2002
- 114 Post(s)
- 0 Thread(s)
$finalArray = array_merge($array1, array_diff($array1, $array2));