note 41400 deleted from function.array-unique by aidan

From: Date: Sun, 12 Sep 2004 07:39:13 +0000
Subject: note 41400 deleted from function.array-unique by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76501@lists.php.net to get a copy of this message
Note Submitter: rj32 at njit dot edu ---- <?php 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; ?> }

« previous php.notes (#76501) next »