Reputation:
probably an already discussed topic, but in Php I did not found an answer Is there a simpler way to realize in what follows:
$a = array("hello","hello","Hello","world","worlD");
$p=array();
foreach( $a as $v ){
$p[strtolower($v)] = "";
}
print_r($p);
keep one single element, in small-case, for the array
Upvotes: 0
Views: 75
Reputation: 655219
You can use array_flip
to swap keys and values:
$a = array_flip(array_map('strtolower', $a));
Upvotes: 0