note 31598 added to ref.array

From: Date: Sun, 27 Apr 2003 20:03:16 +0000
Subject: note 31598 added to ref.array
Groups: php.notes 
Request: Send a blank email to php-notes+get-47176@lists.php.net to get a copy of this message
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; } -- http://www.php.net/manual/en/ref.array.php http://master.php.net/manage/user-notes.php?action=edit+31598 http://master.php.net/manage/user-notes.php?action=delete+31598 http://master.php.net/manage/user-notes.php?action=reject+31598

« previous php.notes (#47176) next »