note 31598 deleted from ref.array by didou

From: Date: Sun, 18 May 2003 01:24:20 +0000
Subject: note 31598 deleted from ref.array by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-48320@lists.php.net to get a copy of this message
Note Submitter: jmoponfire@hotmail.com ---- Removing Duplicate elements A function that takes a indexed one-dimensional array and returns an array containing the unique values of the first array: function removeduplicates($x) { $i = sizeof($x); if($i>1) { $q=0; $y = array(); $z = array(); for($k=0;$k<$i-1;$k++) { $flag = 0; for($j=$k+1;$j<$i;$j++) { if($x[$k] == $x[$j]) { $flag=1; } } $y[$k] = $flag; } $y[$i-1] = 0; $j=0; for($k=0;$k<$i;$k++) { if($y[$k]!= 1) { $z[$j] = $x[$k]; $j++; } } } else $z=$x; return $z; }

« previous php.notes (#48320) next »