note 94492 deleted from function.array-diff by danbrown

From: Date: Sun, 08 Nov 2009 16:14:52 +0000
Subject: note 94492 deleted from function.array-diff by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162636@lists.php.net to get a copy of this message
Note Submitter: to Anonymous ---- to Anonymous post, posted on 15-Oct-2009 06:55: quote: "So, as an example: A = 1,2,3 B = 2,3,4 should NOT be: C = 1,4 but: A = 1 B = 4" I think you're wrong. This function "Returns an array containing all the entries from array1 that are not present in any of the other arrays." So you would get C = 1, and NOT C = 1,4. So you could just do it like that: <?php $original = array(1,2,3); $new = array(2,3,4); $delete = array_diff($original, $new); // array(1) $insert = array_diff($new, $original); // array(4) ?>

« previous php.notes (#162636) next »