note 103964 added to function.array-unique
| From: | iim dot vxk at gmail dot com | Date: | Fri, 13 May 2011 22:50:47 +0000 |
| Subject: | note 103964 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179707@lists.php.net to get a copy of this message | ||
/* SORRY ignore my previous post, this code is updated */
// an easiest way to get unique AND duplicated items...
$unique=array("","A1","","A2","","A1","");
$duplicated=array();
foreach($unique as $k=>$v) {
if( ($kt=array_search($v,$unique))!==false and $k!=$kt )
{ unset($unique[$kt]); $duplicated[]=$v; }
}
var_export($unique);
var_export($duplicated);
// will output
array ( 3 => 'A2', 5 => 'A1', 6 => '', )
array ( 0 => '', 1 => '', 2 => 'A1', 3 => '', )
/* SORRY =P */
----
Server IP: 64.71.164.2
Probable Submitter: 187.156.88.169
----
Manual Page -- http://www.php.net/manual/en/function.array-unique.php
Edit -- https://master.php.net/note/edit/103964
Del: integrated -- https://master.php.net/note/delete/103964/integrated
Del: useless -- https://master.php.net/note/delete/103964/useless
Del: bad code -- https://master.php.net/note/delete/103964/bad+code
Del: spam -- https://master.php.net/note/delete/103964/spam
Del: non-english -- https://master.php.net/note/delete/103964/non-english
Del: in docs -- https://master.php.net/note/delete/103964/in+docs
Del: other reasons-- https://master.php.net/note/delete/103964
Reject -- https://master.php.net/note/reject/103964
Search -- https://master.php.net/manage/user-notes.php