In a project I needed to replicate the way pandoc makes hash slugs in HTML documents. I came up with this method:
function generatePandocLink ($title) {
$title = preg_replace("/[^[:alnum:][:space:]]/u", '', $title);
$title = str_replace(' ', '-', $title);
$title = trim($title, '-');
$title = mb_strtolower($title, 'UTF8');
return $title;
}
Worked perfect.
This page has been requested 8768 times