note 82508 added to function.array-unique
| From: | PHPExpert at osu1 dot php dot net | Date: | Mon, 14 Apr 2008 12:34:19 +0000 |
| Subject: | note 82508 added to function.array-unique | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138293@lists.php.net to get a copy of this message | ||
case insensitive for PHP v4.x and up.
<?php
function in_iarray($str, $a){
foreach($a as $v){
if(strcasecmp($str, $v)==0){return true;}
}
return false;
}
function array_iunique($a){
$n = array();
foreach($a as $k=>$v){
if(!in_iarray($v, $n)){$n[$k]=$v;}
}
return $n;
}
$input =
array("aAa","bBb","cCc","AaA","ccC","ccc","CCC","bBB","AAA","XXX");
$result = array_iunique($input);
print_r($result);
/*
Array
(
[0] => aAa
[1] => bBb
[2] => cCc
[9] => XXX
)
*/
?>
----
Server IP: 81.198.190.2
Probable Submitter: 78.157.132.32
----
Manual Page -- http://www.php.net/manual/en/function.array-unique.php
Edit -- https://master.php.net/note/edit/82508
Del: integrated -- https://master.php.net/note/delete/82508/integrated
Del: useless -- https://master.php.net/note/delete/82508/useless
Del: bad code -- https://master.php.net/note/delete/82508/bad+code
Del: spam -- https://master.php.net/note/delete/82508/spam
Del: non-english -- https://master.php.net/note/delete/82508/non-english
Del: in docs -- https://master.php.net/note/delete/82508/in+docs
Del: other reasons-- https://master.php.net/note/delete/82508
Reject -- https://master.php.net/note/reject/82508
Search -- https://master.php.net/manage/user-notes.php