Bon en mieux formuler
<?php
function Enleve_carac($carac, $carac_replace, $chaine){
$carac_enleve=str_replace($carac,"",$chaine); //On enleve tout les caractères qu'on veut garder
$taille=strlen($carac_enleve); //Decomposition pour un faire un tableau des caractères qu'on veut enlever
$tab=array();
for($i=0; $i<$taille;$i++) array_push ($tab,$carac_enleve[$i]);
$chaine=str_replace($tab,$carac_replace,$chaine); //On enleveve tout les caractères indésirables
return($chaine); //resultat final
}
$chaine="Salut 1234!&*Coucou";
$carac= 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","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",
"1","2","3","4","5","6","7","8","9","0", " "
); //Caractères qu'on veut garder
$carac_replace="_" ; //Caractère qui va faire le remplacement
$mot=Enleve_carac($carac,$carac_replace,$chaine);
echo($chaine);
?>