note 103963 added to function.array-unique

From: Date: Fri, 13 May 2011 22:36:52 +0000
Subject: note 103963 added to function.array-unique
Groups: php.notes 
Request: Send a blank email to php-notes+get-179706@lists.php.net to get a copy of this message
// an easiest way to get unique AND duplicated items... $unique=array("","A1","","A2","","A1",""); $duplicated=array(); foreach($unique as $k=>$v) { while( ($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 => '', ) ---- 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/103963 Del: integrated -- https://master.php.net/note/delete/103963/integrated Del: useless -- https://master.php.net/note/delete/103963/useless Del: bad code -- https://master.php.net/note/delete/103963/bad+code Del: spam -- https://master.php.net/note/delete/103963/spam Del: non-english -- https://master.php.net/note/delete/103963/non-english Del: in docs -- https://master.php.net/note/delete/103963/in+docs Del: other reasons-- https://master.php.net/note/delete/103963 Reject -- https://master.php.net/note/reject/103963 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179706) next »