Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/09/2009, 10:05
Gatoh
 
Fecha de Ingreso: octubre-2008
Mensajes: 12
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: Problema función para URL amigable.

Así funciona bien:

Código PHP:
function amigable($str) {

    
$search = array('<''>''"''&');    
    
$str str_replace($search''$str);
    
    
$search = array('á','Á','é','É','í','Í','ó','Ó','ú','Ú','ñ','Ñ');
    
$replace = array('a','a','e','e','i','i','o','o','u','u','n','n');
    
    
$search = array('Á''É''Í''Ó''Ú''á''é''í''ó''ú''Ü''ü''Ñ''ñ''_''-');
    
$replace = array('a''e''i''o''u''a''e''i''o''u''u''u''n''n'' '' ');
    
    
$str str_replace($search$replace$str);
    
    
$str preg_replace('/&(?!#[0-9]+;)/s'''$str);

    
$search = array(' a '' ante '' de '' para '' con '' contra '' por '' entre '' en '' sobre '' bajo '' y '' e '' o '' u '' este ',  'aquel '' la '' el '' lo '' las '' los ');

    
$str str_replace($search' 'strtolower($str));

    
$str str_replace($search$replacestrtolower(trim($str)));
    
    
$str preg_replace("/[^a-zA-Z0-9\s]/"''$str);
    
$str preg_replace('/\s\s+/'' '$str);
    
$str str_replace(' ''-'$str);

    return  
$str;