/** * Calculate diff of multidimensional and hierarchical arrays * @param array $value1 * @param array $value2 * @param mixed $diff Result of diff * @return boolean If or not differ */ function wa_array_diff_r($value1, $value2, &$diff) { if (is_array($value1) && is_array($value2)) { $kyes = array_unique(array_merge(array_keys($value1), array_keys($value2))); $result = false; foreach ($kyes as $k) { $v1 = ifset($value1[$k]); $v2 = ifset($value2[$k]); $r = wa_array_diff_r($v1, $v2, $diff[$k]); if (!$r) { unset($diff[$k]); } $result = $result || $r; } return $result; } elseif ($value1 !== $value2) { $diff = $value1; return true; } else { return false; } }
public function logProfileEdit($old_data, $new_data) { $diff = array(); wa_array_diff_r($old_data, $new_data, $diff); if (!empty($diff)) { $this->logAction('my_profile_edit', $diff, null, $this->contact->getId()); } }
public function logContactEdit($old_data, $new_data) { $diff = array(); wa_array_diff_r($old_data, $new_data, $diff); if (!empty($diff)) { $this->logAction('contact_edit', $diff, $this->contact->getId()); } }