I am using codeigniter. I want difference of two array as I am using array_diff
function of php. Due to associative array, I have used call_user_func_array
and I got record.
$result_sun = call_user_func_array('array_merge', $data['sun_holiday']);
$result_sat = call_user_func_array('array_merge', $data['third_sat']);
But when I am going to make difference of these two array like,
$result = array_diff($result_sun,$result_sat);
It only shows the record of first array $result_sun
.
$result_sun = Array
(
[0] => 2015-09-06
[1] => 2015-09-13
[2] => 2015-09-20
[3] => 2015-09-27
)
$result_sat = Array
(
[0] => 2015-09-19
)
So, why the difference is not occurring??
$result1 = array_diff($result_sun,$result_sat);
$result2 = array_diff($result_sat,$result_sun);
$result=array_merge($result1,$result2);
Compares $result_sun against one or more other arrays and returns the values in $result_sun that are not present in any of the other arrays. so take difference of both and then merge it will be good if you put your code then we can give more accurate answer