How to Create URL Slug from String in PHP
function slugify($urlString) {
$search = array(‘Ș’, ‘Ț’, ‘ş’, ‘ţ’, ‘Ş’, ‘Ţ’, ‘ș’, ‘ț’, ‘î’, ‘â’, ‘ă’, ‘Î’, ‘ ‘, ‘Ă’, ‘ë’, ‘Ë’);
$replace = array(‘s’, ‘t’, ‘s’, ‘t’, ‘s’, ‘t’, ‘s’, ‘t’, ‘i’, ‘a’, ‘a’, ‘i’, ‘a’, ‘a’, ‘e’, ‘E’);
$str = str_ireplace($search, $replace, strtolower(trim($urlString)));
$str = preg_replace(‘/[^\w\d\-\ ]/’, », $str);
$str = str_replace(‘ ‘, ‘-‘, $str);
return preg_replace(‘/\-{2,}’, ‘-‘, $str);
}