Commit 55bda179 authored by N. Peraldi's avatar N. Peraldi

optimize createNameClass() function

parent d10db461
......@@ -44,13 +44,40 @@ function createFirstSelectionList($liste)
function createNameClass($variable)
{
//fonction qui nettoie la chaine pour pouvoir l'utiliser en tant que nom de classe
$variable = str_replace("é", "e", $variable);
$variable = str_replace("è", "e", $variable);
$variable = str_replace("à", "a", $variable);
$variable = str_replace("ç", "c", $variable);
$variable = str_replace("ù", "u", $variable);
$variable = str_replace(" ", "_", $variable);
$chars = array(
//tous les caractères susceptibles d'être remplacés
"é" => "e",
"è" => "e",
"ê" => "e",
"ë" => "e",
"à" => "a",
"â" => "a",
"ù" => "u",
"û" => "u",
"î" => "i",
"ï" => "i",
"ç" => "c",
"É" => "e",
"È" => "e",
"Ê" => "e",
"Ë" => "e",
"À" => "a",
"Â" => "a",
"Ù" => "u",
"Û" => "u",
"Î" => "i",
"Ï" => "i",
"Ç" => "c",
" " => "_"
);
$variable = strtr($variable,$chars);
return $variable;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment