Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/04/2011, 09:56
Hidek1
Colaborador
 
Fecha de Ingreso: octubre-2009
Ubicación: Tokyo - Japan !
Mensajes: 3.867
Antigüedad: 17 años
Puntos: 334
Respuesta: Función que funciona diferente según el entorno

eso se debe a la codificacion de los caracteres entrantes
prueba esto

Código PHP:
$foo = 'acentos_á_é_í_ó_ú_ñ';
$foo = utf8_decode($foo);
echo 
Khaus_Uri_Seo::safeName($foo); 
tambien podrias editar la linea del codigo

Código PHP:
class Khaus_Uri_Seo
{
    static public function 
removeAccents($string)
    {
        
$html = get_html_translation_table(HTML_ENTITIES);
        
$html = array_slice($html, 32, -4);
        foreach (
$html as $char => $entitie) {
            
$bar[] = substr($entitie, 1, 1);
        }
        
$string = htmlentities($string, ENT_QUOTES, 'UTF-8'); // agregado para problema con codificacion
        
$string = str_replace($html, $bar, $string);
        return 
$string;
    }
    static public function 
safeName($string)
    {
        
$string = self::removeAccents($string);
        
$string = strtolower($string);
        
$string = preg_replace('/(&[a-z0-9]+;|[^a-z0-9_])/', '_', $string);
        
$string = preg_replace('/[\s_]+/', '_', $string);
        
$string = trim($string, '_');
        return 
$string;
    }
} 

Última edición por Hidek1; 20/04/2011 a las 10:03