I have basic code like this I am using to translate a website:
function getTranslataion($db_value)
{
global $db_array;
if (array_key_exists(strtolower($db_value), $db_array)) {
return $db_array[$db_value];
}
return $db_value;
}
I also do a reverse lookup an pull up key's based on value:
function findTranslataion($displayed_string)
{
global $db_array;
$key = array_search(strtolower($displayed_string), $db_array);
if (strlen($key) > 0) {
return $key;
}
return $displayed_string;
}
For example, the array
may look like this:
$db_array = array ( "Yes" = > "si", "No" => "No );
Now for the word "Si", it can also be typed as "Sí" (with an accent). The user may or may not type "Si" with an accent mark depending on their keyboard, etc. So is there a way to do these type of searches and ignore all types of variations of, for example, the letter "i" and just match it with the array
key or value?