Skip to content

Instantly share code, notes, and snippets.

@zephster
Created February 12, 2015 19:56
Show Gist options
  • Save zephster/fc5df03aed7458b43ef7 to your computer and use it in GitHub Desktop.
Save zephster/fc5df03aed7458b43ef7 to your computer and use it in GitHub Desktop.
private function _diff($old, $new)
{
$diffs = array();
foreach ($old as $section => $v)
{
if (is_array($v))
{
$array_diffs = $this->_diff($v, $new[$section]);
if (!empty($array_diffs))
$diffs[$section] = (isset($array_diffs[0]) ? $array_diffs[0] : $array_diffs);
}
else
{
// sabre often doesn't have certain, specific pieces of data that we do have,
// and we don't want to blank out our data, so skip any blanks
if ($new[$section] != $v && !empty($new[$section]))
{
$diffs[$section]['old'] = $v;
$diffs[$section]['new'] = $new[$section];
}
}
}
return $diffs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment