note 100164 added to function.in-array
| From: | miizhar at aol dot com | Date: | Wed, 29 Sep 2010 02:30:32 +0000 |
| Subject: | note 100164 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172795@lists.php.net to get a copy of this message | ||
<?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,
----
Server IP: 117.55.229.1
Probable Submitter: 58.175.148.126
----
Manual Page -- http://www.php.net/manual/en/function.in-array.php
Edit -- https://master.php.net/note/edit/100164
Del: integrated -- https://master.php.net/note/delete/100164/integrated
Del: useless -- https://master.php.net/note/delete/100164/useless
Del: bad code -- https://master.php.net/note/delete/100164/bad+code
Del: spam -- https://master.php.net/note/delete/100164/spam
Del: non-english -- https://master.php.net/note/delete/100164/non-english
Del: in docs -- https://master.php.net/note/delete/100164/in+docs
Del: other reasons-- https://master.php.net/note/delete/100164
Reject -- https://master.php.net/note/reject/100164
Search -- https://master.php.net/manage/user-notes.php