note 41400 added to function.array-unique

From: Date: Thu, 08 Apr 2004 16:03:01 +0000
Subject: note 41400 added to function.array-unique
Groups: php.notes 
Request: Send a blank email to php-notes+get-67829@lists.php.net to get a copy of this message
function unique_array($arrayOld,$primaryKeyId=0) { $arrayNew=array(); $searchArray=array(); $counter=0; array_push($searchArray,$arrayOld[$primaryKeyId]); $arrayNew[$counter++]=$arrayOld[$primaryKeyId]; for($i=0;$i<count($arrayOld);$i++) { if(array_search(trim($arrayOld[$i][$primaryKeyId]),$searchArray)==0) { $arrayNew[$counter++]=$arrayOld[$i]; array_push($searchArray,trim($arrayOld[$i][$primaryKeyId])); } } return $arrayNew; } ---- Manual Page -- http://www.php.net/manual/en/function.array-unique.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41400 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41400&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41400&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67829) next »