note 108574 deleted from function.array-diff by danbrown

From: Date: Thu, 10 May 2012 16:43:34 +0000
Subject: note 108574 deleted from function.array-diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-187585@lists.php.net to get a copy of this message
Note Submitter: psynnott at gmail dot com ---- My task: Compare an array before and after an operation and be able to tell what was added and what was deleted. What I did: Read a ton of these comments and found several very convoluted solutions. What I then did: Engage the brain and re-read the manual for array_diff() What I came up with: 2 lines of functional code: $before = array(1,2,3); $after = array(2,4,5); $toDelete = array_diff($before,$after); $toAdd = array_diff($after,$before);

« previous php.notes (#187585) next »