I am using following slugify method,in my local dev its working fine,but in my production server(CentOs) and the PCRE UTF8 supported but "No Unicode properties support".
function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
if (function_exists('iconv')) {
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
}
// lowercase
$text = strtolower($text);
// remove unwanted characters
$text = preg_replace('~[^-\w]+~', '', $text);
if (empty($text)) {
return 'n-a';
}
return $text;
}
And preg_replace is not working there,is there any method that can work as preg_replace,or any slugify muthod that can work as the above function.
Thanks in advance.
$trans = array('ä' => 'a', 'å' => 'a', 'ö' => 'o'); $slug = strtr($string, $trans);. After the translations have been done, discard anything other thanA-Za-z0-9.us-asciicharset? And you have two regexes, which one fails? Are you getting an error message?