Return to Snippet

Revision: 17994
at September 19, 2009 00:13 by fetolio


Updated Code
function tourl($strText) {
    $strText = preg_replace('/ã|â|á|ä|à/i','a',$strText);
    $strText = preg_replace('/ê|é|ë|è/i','e',$strText);
    $strText = preg_replace('/î|í|ï|ì/i','i',$strText);
    $strText = preg_replace('/õ|ô|ó|ö|ò/i','o',$strText);
    $strText = preg_replace('/û|ú|ü|ù/i','u',$strText);
    $strText = str_ireplace(array('ç','ñ'),array('c','n'),$strText);
    $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText);
    $strText = preg_replace('/ +/', ' ', $strText);
    $strText = trim($strText);
    $strText = str_replace(' ', '-', $strText);
    $strText = preg_replace('/-+/', '-', $strText);
    $strText = strtolower($strText);
    return $strText;
}

Revision: 17993
at September 19, 2009 00:12 by fetolio


Updated Code
function tourl($strText) {
    $strText = preg_replace('/ã|â|á|ä|à/i','a',$strText);
    $strText = preg_replace('/ê|é|ë|è/i','e',$strText);
    $strText = preg_replace('/î|í|ï|ì/i','i',$strText);
    $strText = preg_replace('/õ|ô|ó|ö|ò/i','o',$strText);
    $strText = preg_replace('/û|ú|ü|ù/i','u',$strText);
    $strText = str_ireplace(array('ç','ñ'),array('c','n'),$strText);
    $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText);
    $strText = preg_replace('/ +/', ' ', $strText);
    $strText = trim($strText);
    $strText = str_replace(' ', '-', $strText);
    $strText = preg_replace('/-+/', '-', $strText);
    $strText = strtolower($strText);
    return $strText;
}

Revision: 17992
at September 19, 2009 00:08 by fetolio


Initial Code
function tourl($strText) {
	$strText = preg_replace('/ã|â|á|ä|à/i','a',$strText);
	$strText = preg_replace('/ê|é|ë|è/i','e',$strText);
	$strText = preg_replace('/î|í|ï|ì/i','i',$strText);
	$strText = preg_replace('/õ|ô|ó|ö|ò/i','o',$strText);
	$strText = preg_replace('/û|ú|ü|ù/i','u',$strText);
	$strText = str_ireplace(array('ç','ñ'),array('c','n'),$strText);
    $strText = preg_replace('/[^A-Za-z0-9-]/', ' ', $strText);
    $strText = preg_replace('/ +/', ' ', $strText);
    $strText = trim($strText);
    $strText = str_replace(' ', '-', $strText);
    $strText = preg_replace('/-+/', '-', $strText);
    $strText = strtolower($strText);
    return $strText;
}

Initial URL
http://snipplr.com/view.php?codeview&id=9024

Initial Description
I've made some changes

Initial Title
String to URL generator - impoved

Initial Tags
url

Initial Language
PHP