<?php
function urlify($str)
{
    $str = mb_strtolower(trim($str));
    $str = str_replace(
        ['ä', 'ö', 'ü', 'ß', ' '],
        ['ae', 'oe', 'ue', 'ss', '-'],
        $str
    );
    $str = preg_replace('#[^-a-z0-9]#', '', $str);
    $str = str_replace('--', '-', $str);

    $str = implode('-', array_unique(explode('-', $str)));

    return $str;
}
