Skip to content

Instantly share code, notes, and snippets.

@ollym
Created January 25, 2010 16:09
Show Gist options
  • Save ollym/285967 to your computer and use it in GitHub Desktop.
Save ollym/285967 to your computer and use it in GitHub Desktop.
/**
* Returns a list containing items in need of deleteing, and item's in need of adding.
*
* list($adding, $deleting) = arr::diff($source, $current);
*
* @param array The new array.
* @param array The existing array.
* @returns array
*/
public static function diff(array $source, array $current)
{
// Uses a two way array_diff algorithm to calculate the differences
return array(
array_diff($source, $current),
array_diff($current, $source)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment