case-insensitive array_unique
function array_iunique( $array ) {
return array_intersect_key(
$array,
array_unique( array_map( "strtolower", $array ) )
);
}
You're setting both lvalue
and uvalue
to the lower case version.
$uvalue = strtolower($value);
should be
$uvalue = strtoupper($value);
That said, this might be a little faster. The performance of your function will degrade exponentially, while this will be more or less linear (at a guess, not a comp-sci major...)
<?php
function array_iunique($ar) {
$uniq = array();
foreach ($ar as $value)
$uniq[strtolower($value)] = $value;
return array_values($uniq);
}
?>