Felix Kunsmann
Kurz weg …
PHP:
<?php
function makeStringToURL($string)
{
$string = strtolower($string);
$r = array(
"ß" => "ss",
"ä" => "ae",
"ö" => "oe",
"ü" => "ue"
);
foreach ($r as $replace => $search) {
$string = str_replace($replace, $search, $string);
}
$string = preg_replace('/[\(\)\[\]\{\}]/', '', $string);
$string = preg_replace('/[^a-z0-9-]/', '-', $string);
$string = preg_replace('/-{2,}/', '-', $string);
if (substr($string, 0, 1) == "-") {
$string = substr($string, 1);
}
if (substr($string, -1) == "-") {
$string = substr($string, 0, -1);
}
return $string;
}
?>