PHPize Online / SQLize Online

A A A
Share   Donate   Blog   Popular
Copy Format Clear
Copy
Copy Format Clear
<?php $arr1 = [ 33 => [ 0 => 30319, 1 => 30318, 2 => 30315, 3 => 50209 ] ]; $arr2 = [ 33 => [ 0 => 50209, 1 => 50149, 2 => 30315, ], 32 => [ 0 => 12345 ] ]; $arr2keys = array_keys($arr2); $arr1keys = array_keys($arr1); $dif = []; foreach (array_merge(array_values($arr1keys), array_values($arr2keys)) as $k) { if (is_array($arr1[$k])) { $dif[$k] = array_diff($arr1[$k], $arr2[$k]); } else { $dif[$k] = $arr2[$k]; } } print_r($dif);
Show:  
Copy