Return to Snippet

Revision: 43253
at November 5, 2011 02:37 by KabuqueJoe


Updated 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)),'-');
	}

?>

Revision: 43252
at April 29, 2011 23:51 by KabuqueJoe


Updated 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','s','y','-','','-');
		return trim(preg_replace($a, $b, strtolower($str)),'-');
	}
?>

Revision: 43251
at March 21, 2011 04:21 by KabuqueJoe


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

Revision: 43250
at March 21, 2011 04:20 by KabuqueJoe


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

Revision: 43249
at March 21, 2011 04:15 by KabuqueJoe


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

Revision: 43248
at March 21, 2011 04:12 by KabuqueJoe


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

Revision: 43247
at March 21, 2011 04:12 by KabuqueJoe


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

Revision: 43246
at March 20, 2011 07:27 by KabuqueJoe


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

Revision: 43245
at March 20, 2011 07:21 by KabuqueJoe


Updated Code
<?php
	function seoUrl($str){
		/** by Jonatas Urias B Teixeira	**/
		$a = array('/(&Atilde;&nbsp;|&Atilde;&iexcl;|&Atilde;&cent;|&Atilde;&pound;|&Atilde;&curren;|&Atilde;&yen;|&Atilde;&brvbar;)/','/(&Atilde;&uml;|&Atilde;&copy;|&Atilde;&ordf;|&Atilde;&laquo;)/','/(&Atilde;&not;|&Atilde;&shy;|&Atilde;&reg;|&Atilde;&macr;)/','/(&Atilde;&deg;|&Atilde;&sup2;|&Atilde;&sup3;|&Atilde;&acute;|&Atilde;&micro;|&Atilde;&para;|&Atilde;&cedil;)/','/(&Atilde;&sup1;|&Atilde;&ordm;|&Atilde;&raquo;|&Atilde;&frac14;)/','/&Atilde;&sect;/','/&Atilde;&frac34;/','/&Atilde;&plusmn;/','/&Atilde;Ÿ/','/(&Atilde;&frac12;|&Atilde;&iquest;)/','/(=|\+|\/|\\|\.|\'|\_|\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s','/([^a-z]*)([a-z-]*)([^a-z])/','/(=|\+|\/|\\\|\.|\'|\_|\\n| |\(|\))/','/[^a-z0-9_ -]/s','/-{2,}/s','/([^a-z]*)([a-z-]*)([^a-z])/');
		$b = array('a','e','i','o','u','c','d','n','s','y','-','','-',"$2");
		return trim(trim(preg_replace($a, $b, strtolower($str))),'-');
	}
?>

Revision: 43244
at March 20, 2011 06:03 by KabuqueJoe


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

Revision: 43243
at March 20, 2011 05:59 by KabuqueJoe


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

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

Initial Description
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"

Initial Title
PHP SEO url string filter

Initial Tags
url, php

Initial Language
PHP