Posted By

silverius on 06/10/10


Tagged

spanish seo permalinks slup


Versions (?)

PHP spanish Slug (spanish SEO permalinks)


 / Published in: PHP
 

  1. public static function reemplazo($url = NULL)
  2. {
  3. //Reemplazamos caracteres especiales latinos en Mayúscula por culpa de un bug con strtolower
  4. $table = array(
  5. 'Á'=>'A',
  6. 'Ç'=>'c',
  7. 'É'=>'e',
  8. 'Í'=>'i',
  9. 'Ñ'=>'n',
  10. 'Ó'=>'o',
  11. 'Ú'=>'u',
  12. 'á'=>'a',
  13. 'ç'=>'c',
  14. 'é'=>'e',
  15. 'í'=>'i',
  16. 'ñ'=>'n',
  17. 'ó'=>'o',
  18. 'ú'=>'u',
  19. );
  20. $url = strtr($url, $table);
  21. //Añadimos los guiones
  22. $url = strtolower(trim($url));
  23. $url = preg_replace('/[^a-z0-9-]/', '-', $url);
  24. $url = preg_replace('/-+/', "-", $url);
  25. return $url;
  26. unset($url);
  27. }

Report this snippet  

You need to login to post a comment.