PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
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($arr2[$k], $arr1[$k]); } else { $dif[$k] = $arr2[$k]; } } print_r($dif);
Show:  
Copy Clear