1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
<?php
function fileNameFilter($in) {
$search = array ('@[éèêëÊË]@i','@[àâäÂÄ]@i','@[îïÎÏ]@i','@[ûùüÛÜ]@i','@[ôöÔÖ]@i','@[ç]@i','@[ ]@i','@[^a-zA-Z0-9_.]@');
$replace = array ('e','a','i','u','o','c','_','');
return preg_replace($search, $replace, $in);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="post">
<input type="text" name="text" value="aïda">
<input type="submit" name="Submit" value="Submit">
</form>
<?php
if(isset($_POST['text'])){
// reception direct
print "reception direct <b>".$_POST['text']."</b><br/>";
// decode utf8 puis filtre
$dec = utf8_decode($_POST['text']);
$filtre = fileNameFilter($dec);
print "decode filtre <b>".$filtre."</b><br/>";
// réencode après filtrage
$filtreUtf8 = utf8_encode($filtre);
print "filtre encode <b>".$filtreUtf8."</b><br/>";
// reception direct filtrée
$filtreBase = fileNameFilter($_POST['text']);
print "base filtre <b>".$filtreBase."</b><br/>";
}
?> |
Partager