Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
eu axei uma função na net para limpar texto para url, mas qnd eu vo usá tá dando os seguintes erros
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 3 in C:\xampp\htdocs\nti\test.php on line 4
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 3 in C:\xampp\htdocs\nti\test.php on line 5
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 3 in C:\xampp\htdocs\nti\test.php on line 6
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 3 in C:\xampp\htdocs\nti\test.php on line 7
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 2 in C:\xampp\htdocs\nti\test.php on line 8
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 2 in C:\xampp\htdocs\nti\test.php on line 9
Warning: preg_replace() [function.preg-replace]: Compilation failed: invalid UTF-8 string at offset 1 in C:\xampp\htdocs\nti\test.php on line 10
<?php
function clean($texto) {
$texto = html_entity_decode($texto);
$texto = preg_replace('![aáàãâä]+!u','a',$texto);
$texto = preg_replace('![eéèêë]+!u','e',$texto);
$texto = preg_replace('![iíìîï]+!u','i',$texto);
$texto = preg_replace('![oóòõôö]+!u','o',$texto);
$texto = preg_replace('![uúùûü]+!u','u',$texto);
$texto = preg_replace('![ç]+!u','c',$texto);
$texto = preg_replace('![ñ]+!u','n',$texto);
$texto = eregi_replace('( )','-',$texto);
$texto = preg_replace('![^a-z0-9\-]+!u','',$texto);
$texto = eregi_replace('--','-',$texto);
return strtolower($texto);
}
$a = clean('çãó4');
echo $a;
?>
se alguém poder me ajudar eu agradeço muitoCarregando comentários...