note 94492 added to function.array-diff
| From: | toAnonymous at osu1 dot php dot net | Date: | Sun, 08 Nov 2009 13:47:38 +0000 |
| Subject: | note 94492 added to function.array-diff | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162633@lists.php.net to get a copy of this message | ||
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)
?>
----
Server IP: 69.147.83.197
Probable Submitter: 78.60.212.119
----
Manual Page -- http://www.php.net/manual/en/function.array-diff.php
Edit -- https://master.php.net/note/edit/94492
Del: integrated -- https://master.php.net/note/delete/94492/integrated
Del: useless -- https://master.php.net/note/delete/94492/useless
Del: bad code -- https://master.php.net/note/delete/94492/bad+code
Del: spam -- https://master.php.net/note/delete/94492/spam
Del: non-english -- https://master.php.net/note/delete/94492/non-english
Del: in docs -- https://master.php.net/note/delete/94492/in+docs
Del: other reasons-- https://master.php.net/note/delete/94492
Reject -- https://master.php.net/note/reject/94492
Search -- https://master.php.net/manage/user-notes.php