note 103964 deleted from function.array-unique by danbrown

From: Date: Sat, 14 May 2011 01:40:36 +0000
Subject: note 103964 deleted from function.array-unique by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179709@lists.php.net to get a copy of this message
Note Submitter: iim dot vxk at gmail dot com ---- /* 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 */

« previous php.notes (#179709) next »