note 95173 added to function.array-unique
| From: | YoussefOmar at osu1 dot php dot net | Date: | Wed, 16 Dec 2009 19:09:22 +0000 |
| Subject: | note 95173 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-164053@lists.php.net to get a copy of this message | ||
This is how to merge 2 comma separated lists with unique value only.
<?php
$list1 = "4444, 5555, 6666";
$list2 = "4444, 5555, 7777";
// combine both lists with unique values only
$list3 = implode("," ,
array_unique(array_merge(explode(",",$list1),explode(",", $list2))));
echo $list3;
?>
The result is: 4444,5555,6666,7777
----
Server IP: 208.69.120.55
Probable Submitter: 63.249.90.70
----
Manual Page -- http://www.php.net/manual/en/function.array-unique.php
Edit -- https://master.php.net/note/edit/95173
Del: integrated -- https://master.php.net/note/delete/95173/integrated
Del: useless -- https://master.php.net/note/delete/95173/useless
Del: bad code -- https://master.php.net/note/delete/95173/bad+code
Del: spam -- https://master.php.net/note/delete/95173/spam
Del: non-english -- https://master.php.net/note/delete/95173/non-english
Del: in docs -- https://master.php.net/note/delete/95173/in+docs
Del: other reasons-- https://master.php.net/note/delete/95173
Reject -- https://master.php.net/note/reject/95173
Search -- https://master.php.net/manage/user-notes.php