Created
May 25, 2015 09:18
-
-
Save E1101/03831ea7fb2570e06e66 to your computer and use it in GitHub Desktop.
array_intersect case-insensitive and ignoring tildes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function to_lower_and_without_tildes($str,$encoding="UTF-8") { | |
$str = preg_replace('/&([^;])[^;]*;/',"$1",htmlentities(mb_strtolower($str,$encoding),null,$encoding)); | |
return $str; | |
} | |
function compare_function($a,$b) { | |
return to_lower_and_without_tildes($a)===to_lower_and_without_tildes($b)?0:1; | |
} | |
$array1 = array("a" => "gréen", "red", "blue"); | |
$array2 = array("b" => "green", "yellow", "red"); | |
$result = array_uintersect($array1, $array2,"compare_function"); | |
print_r($result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment