Kod
function pl_remove($text)
{
$pl_replace = array(
'ą' => 'a', 'ę' => 'e', 'ś' => 's', 'ć' => 'c', 'ó' => 'o',
'ń' => 'n', 'ż' => 'z', 'ź' => 'z', 'ł' => 'l',
'Ą' => 'A', 'Ę' => 'E', 'Ś' => 'S', 'Ć' => 'C','Ó' => 'O',
'Ń' => 'N', 'Ż' => 'Z', 'Ź' => 'Z', 'Ł' => 'L'
);
return str_replace(array_keys($pl_replace), array_values($pl_replace), $text);
}
Kod
function prepareURL($text)
{
$text = pl_remove($text);
$text = strtolower($text);
$text = str_replace(' ', '-', $text);
$text = preg_replace('/[^0-9a-z\-]+/', '', $text);
$text = preg_replace('/[\-]+/', '-', $text);
$text = trim($text, '-');
return $text;
}
i dajesz
Kod
echo prepareURL('tekst');