Posted By

KabuqueJoe on 03/20/11


Tagged

url php generator String special characters seo


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

uberdragon
voove
trusktr
notturnale


PHP SEO url string filter


 / Published in: PHP
 

URL: http://tinyphp.tumblr.com/post/3750074024/php-seo-url-string-filter

This function will transform any string to an seo url like string. It suports latin, french and german special characters.

Example: applying the function to "Exemplo de aplicação da função" returns "exemplo-de-aplicacao-da-funcao"

  1. <?php
  2.  
  3. function seoUrl($str){
  4. /** by Jonatas Urias B Teixeira **/
  5. $a = array('/(à|á|â|ã|ä|å|æ)/','/(è|é|ê|ë)/','/(ì|í|î|ï)/','/(ð|ò|ó|ô|õ|ö|ø|œ)/','/(ù|ú|û|ü)/','/ç/','/þ/','/ñ/','/ß/','/(ý|ÿ)/','/(=|\+|\/|\\\|\.|\'|\_|\\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s');
  6. $b = array('a','e','i','o','u','c','d','n','ss','y','-','','-');
  7. return trim(preg_replace($a, $b, strtolower($str)),'-');
  8. }
  9.  
  10. ?>

Report this snippet  

You need to login to post a comment.