Results 1 to 2 of 2
-
19th Sep 2015, 05:48 PM #1
SEO url string filter Using PHP
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"
PHP Code:<?php
function seoUrl($str){
/** by Jonatas Urias B Teixeira **/
$a = array('/(à|á|â|ã|ä|å|æ)/','/(è|é|ê|ë)/','/(ì|í|î|ï)/','/(ð|ò|ó|ô|õ|ö|ø|œ)/','/(ù|ú|û|ü)/','/ç/','/þ/','/ñ/','/ß/','/(ý|ÿ)/','/(=|\+|\/|\\\|\.|\'|\_|\\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s');
$b = array('a','e','i','o','u','c','d','n','ss','y','-','','-');
return trim(preg_replace($a, $b, strtolower($str)),'-');
}
?>Kevin Reviewed by Kevin on . SEO url string filter Using PHP 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" <?php function seoUrl($str){ /** by Jonatas Urias B Teixeira **/ $a = array('/(à|á|â|ã|ä|å|æ)/','/(è|é|ê|ë)/','/(ì|í|î|ï)/','/(ð|ò|ó|ô|õ|ö|ø|œ)/','/(ù|ú|û|ü)/','/ç/','/þ/','/ñ/','/ß/','/(ý|ÿ)/','/(=|\+|\/|\\\|\.|\'|\_|\\n| Rating: 5
-
19th Sep 2015, 05:48 PM #2
You can also try below method
The following function will return a SEO friendly URL using a supplied string.
PHP Code:<?php
function seo($string){
$string = preg_replace("`\[.*\]`U","",$string);
$string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string);
$string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string );
$string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string);
$string = htmlentities($string, ENT_COMPAT, 'utf-8');return strtolower(trim($string, '-'));
}
?>
-
The Following 1 Users Say Thank You to Kevin For This Useful Post:
- [ Click to Expand ]
-
BHK (21st Sep 2015)
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Vn5socks.net 05-11-2024 | Service...
Live | 198.7.56.71:58182 | United States |...