note 100164 deleted from function.in-array by danbrown

From: Date: Wed, 29 Sep 2010 02:34:48 +0000
Subject: note 100164 deleted from function.in-array by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172796@lists.php.net to get a copy of this message
Note Submitter: miizhar at aol dot com ---- <?php function remove_duplicates_in_array ($x){ $y= array(); $j=0; for($i = 0, $ii = count($x); $i < $ii; $i++){ if(!in_array($x[$i], $y)) { $y[$j] = $x[$i]; $j++; } } return $y; } $names = array('jack', 'tes', 'dave', 'jack', 'torri', 'eli', 'suzi', 'dave'); for($i = 0, $ii = count($names);$i<$ii;$i++) echo $names[$i].', '; $names = remove_duplicates_in_array($names); echo'<br/>'; for($i=0, $ii = count($names); $i < $ii; $i++) echo $names[$i].', '; ?> prints jack, tes, dave, torri, eli, suzi,

« previous php.notes (#172796) next »