<?php
static public function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
$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;
}
$string = "andrés EFI收购Cretaprint";
echo slugify($string);
- Output for 5.4.0 - 5.4.15
- Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in GRaHZ on line 3
Process exited with code 255. - Output for 5.3.25
- Parse error: syntax error, unexpected T_PUBLIC, expecting T_PAAMAYIM_NEKUDOTAYIM in /in/M0hcp on line 3
Process exited with code 255. - Output for 5.3.0 - 5.3.24
- Parse error: syntax error, unexpected T_PUBLIC, expecting T_PAAMAYIM_NEKUDOTAYIM in GRaHZ on line 3
Process exited with code 255.
preferences:
176.56 ms | 1395 KiB | 49 Q