Skip to content

Instantly share code, notes, and snippets.

@gimenete
Created August 5, 2010 16:15
Show Gist options
  • Save gimenete/509961 to your computer and use it in GitHub Desktop.
Save gimenete/509961 to your computer and use it in GitHub Desktop.
<?php
function seo($url) {
$url = strToLower($url);
$url = str_replace(
array("á", "é", "í", "ó", "ú", "ñ", "ü"),
array("a", "e", "i", "o", "u", "n", "u"),
$url);
$tokens = preg_split("/[^a-zA-Z0-9]+/", $url);
$url = implode("-", $tokens);
$url = trim($url, "-");
return $url;
}
echo seo(" Extraño alijo hampón: güisqui; kiwi, vid y ... ¡¿bizc8?! ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment