Jump to content

[PHP] Prob de convertion


bsh34

Recommended Posts

Voila, j'ai besoin de convertir des majuscules en minuscules et caractères spéciaux en rien "" qui sont rentrer dans un formulaire.

Pour ça, j'utilise une fonction faites maison pour tout convertir. Avant j'utilisais strtolower pour les majuscules mais finalement j'ai tout regrouper la dedans, voila tout le début du code avec l'ancien strlolower en commentaire ( au cas où :roll: )

<?

$name=$_POST["nom"];
$mdp=$_POST["password"];
$opt=$_POST["option"];


#$name= strtolower($name);
#$mdp= strtolower($mdp);
#$opt= strtolower($opt);


function suppaccents($name)
{
$accents = array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y",
"Z","À","Á","Â","Ã","Ä","Å","à","á","â","ã","ä","å","Ò","Ó","Ô","Õ","Ö","Ø","ò","ó","ô","õ","ö","ø","È","É","Ê","Ë","è",
"é","ê","ë","Ç","ç","Ì","Í","Î","Ï","ì","í","î","ï","Ù","Ú","Û","Ü","ù","ú","û","ü","ÿ","Ñ","ñ",":",",",".",";","?","!","~","'","´"
,"(",")","/","&","%","*","\\","\"","$","[","]","{","}","|");
# passage à la ligne rajouter sur le forum pour pas mettre toute la mise en page du site en l'air
$ssaccents = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","a","a","a","a",
"a","a","a","a","a","a","a","a","o","o","o","o","o","o","o","o","o","o","o","o","e","e","e","e","e","e","e","e","c","c","i",
"i","i","i","i","i","i","i","u","u","u","u","u","u","u","u","y","n","n","","","","","","","","","","","","","","","","","","","","","",
"","" );
# passage à la ligne rajouter sur le forum pour pas mettre toute la mise en page du site en l'air
$name = str_replace($accents,$ssaccents,$name);

return($name);
}

$name = suppaccents($name);
echo $name

$enreg=fopen(". ... etc
?>

Le problème est que les caractères éèêëà etc sont affcher a�leve sous firefox et a?la?ves sous ie (en plus que mon code HTML ne soient plus compatibles IE, mais c'est une autre histroire CSS)

Alors voila, je ne comprends pas pourquoi les caractères majuscules sont bien converti, les spéciaux aussi mais pas les accents (alors que c'est le but premier, les majuscules je peux utiliser strlolower pour le faire :p )

Et si qq'un a mieux en plus court et qui marche surtout, je suis preneur :francais:

Merci d'avance

Link to comment
Share on other sites

heuu bêtement :

  function suppaccents($text){

	$text= strtr($text,  "ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ",
	"aaaaaaaaaaaaooooooooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");

	 return $text; 

   }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Guest
This topic is now closed to further replies.
×
×
  • Create New...