Fautes de frappes";
echo "
Oubli de lettres :
";
echo oubli_lettres($kw);
echo "Inversion de lettres :
";
echo inversion_lettres($kw);
echo "Doubler lettres :
";
echo doubler_lettres($kw);
echo "Fautes de frappe courantes :
";
echo erreur_lettres_proches($kw);
////////////////////////Fonctions/////////////////////////
//oubli de lettres
function oubli_lettres($sld)
{
$array = preg_split('//',$sld);
$size = sizeof($array);
$size = $size - 1;
for ($i = 1; $i < $size; $i++)
{
if (!strcmp($array[ $i]," ")) { continue; }
for ($x = 1; $x < $size; $x++)
{
if ($x == $i) { continue; }
$temp = $temp . $array[ $x];
}
print "$temp ";
$temp = "";
}
}
//Inversion lettres
function inversion_lettres($sld)
{
$array = preg_split('//',$sld);
$size = sizeof($array);
$size = $size - 1;
for ($i = 1; $i < $size; $i++)
{
if (!strcmp($array[ $i]," ")) { continue; }
if (!strcmp($array[ $i],$array[ $i+1])) { continue; }
for ($x = 1; $x < $size; $x++)
{
if (($x == $i) and ($i < $size)) { $temp = $temp . $array[ $x+1]; }
else if ($x == ($i+1)) {$temp = $temp . $array[ $x-1]; }
else { $temp = $temp . $array[ $x]; }
}
print "$temp ";
$temp = "";
}
}
//Doubler lettres
function doubler_lettres($sld)
{
$array = preg_split('//',$sld);
$size = sizeof($array);
$size = $size - 1;
for ($i = 1; $i < $size; $i++)
{
if (!strcmp($array[ $i]," ")) { continue; }
for ($x = 1; $x < $size; $x++)
{
$temp = $temp . $array[ $x];
if ($x == $i) { $temp = $temp . $array[ $x] ; }
}
print "$temp ";
$temp = "";
}
}
//Erreur communes clavier azerty
function erreur_lettres_proches($sld)
{
$alphabet = Array(
a => array("z"),
z => array("a", "e"),
e => array("z", "r"),
r => array("e", "t"),
t => array("r", "y"),
y => array("t", "u"),
u => array("y", "i"),
i => array("u", "o"),
o => array("i", "p"),
p => array("o"),
q => array("s"),
s => array("q", "d"),
d => array("s", "f"),
f => array("d", "g"),
g => array("f", "h"),
h => array("g", "j"),
j => array("h", "k"),
k => array("j", "l"),
l => array("k", "m"),
m => array("l"),
w => array("x"),
x => array("w", "c"),
c => array("x", "v"),
v => array("c", "b"),
b => array("v", "n"),
n => array("b")
);
$sld = strtolower($sld);
$array = preg_split('//',$sld);
$size = sizeof($array);
$size = $size - 1;
for ($i = 1; $i < $size; $i++)
{
if (!strcmp($array[ $i]," ")) { continue; }
$current_letter = $array[$i];
if ( !$alphabet[$current_letter][0] ) { continue; }
$number_of_missed_keys = sizeof($alphabet[$current_letter]);
for ($x = 0; $x < $number_of_missed_keys; $x++)
{
for ($z = 1; $z < $size; $z++)
{
if ($i == $z) { $temp = $temp . $alphabet[$current_letter][$x] ; }
else { $temp = $temp . $array[ $z]; }
}
print "$temp ";
$temp = "";
}
}
}
////////////////////////Fin Fonctions/////////////////////////
?>