This is my slugify
function:
function slugify($text) {
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
$text = trim($text, '-');
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
$text = mb_strtolower($text, 'UTF-8');
$text = preg_replace('~[^-\w]+~', '', $text);
if(empty($text)) return 'n-a';
return $text;
}
This is the test:
echo slugify("españa");
In my development server the result is:
- espana
In my production server the result is:
- espaa
I'm sure it has something to do with charset encoding, but both servers have UTF-8
as default_charset
. What else could I be missing? Any ideas?