3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_diff_assoc_recursive($array1, $array2) { foreach($array1 as $key => $value) { if(is_array($value)) { if(!isset($array2[$key])) { $difference[$key] = $value; } elseif(!is_array($array2[$key])) { $difference[$key] = $value; } else { $new_diff = array_diff_assoc_recursive($value, $array2[$key]); if($new_diff != FALSE) { $difference[$key] = $new_diff; } } } elseif(!isset($array2[$key]) || $array2[$key] != $value) { $difference[$key] = $value; } } return !isset($difference) ? 0 : $difference; } $a=["original_data"=>[ [ 'reference_id' => 122, 'id' => 121, 'reference_name' => 'Balasuresh' ],[ 'reference_id' => 123, 'id' => 120, 'reference_name' => 'Balasuresh' ] ], 'edited_data' => [[ 'reference_id' => 123, 'id' => 120, 'reference_name' => 'Balasuresh Test' ]] ]; print_r(array_diff_assoc_recursive($a['edited_data'], $a['original_data']));

preferences:
39.85 ms | 402 KiB | 5 Q