1function array_diff_assoc_recursive($array1, $array2) {
2 $difference=array();
3 foreach($array1 as $key => $value) {
4 if( is_array($value) ) {
5 if( !isset($array2[$key]) || !is_array($array2[$key]) ) {
6 $difference[$key] = $value;
7 } else {
8 $new_diff = array_diff_assoc_recursive($value, $array2[$key]);
9 if( !empty($new_diff) )
10 $difference[$key] = $new_diff;
11 }
12 } else if( !array_key_exists($key,$array2) || $array2[$key] !== $value ) {
13 $difference[$key] = $value;
14 }
15 }
16 return $difference;
17}
18//----------------------
19$changes = array();
20if ($result= array_diff_assoc_recursive($new_value,$old_value)) {
21 $new = array();
22
23 foreach ($result as $key => $value) {
24 $new[$key] = $value;
25 }
26 // indicate your UNIQUE ID you can use this when you want know which row you wanted to update in database
27 $new['ID'] = $new_value['ID'];
28 $changes[] = $new ;
29}
30
31print_r($changes);