<?php
$strings = [
'This, is - - the URL!',
'Holmes & Yoyo',
'L’Œil de démon',
'How to win 1000€?',
'€, $ & other currency symbols',
'Und die Katze fraß alle mäuse.',
'Яростта на живота в София',
'പോണ്ടിച്ചേരിയിൽ താമസിക്കുന്നതിന്റെ ക്രോധം',
];
$rules = <<<'RULES'
# Transliteration
:: Any-Latin ; :: Latin-Ascii ;
# examples of custom replacements
'&' > ' and ';
[^0-9][01]? { € > ' euro'; € > ' euros';
[^0-9][01]? { '$' > ' dollar'; '$' > ' dollars';
:: Null;
# slugify
[^[:alnum:]&[:ascii:]]+ > '-';
:: Lower ;
# trim
[$] { '-' > &Remove();
'-' } [$] > &Remove();
RULES;
$tsl = Transliterator::createFromRules($rules, Transliterator::FORWARD);
$results = array_map(fn($s) => $tsl->transliterate($s), $strings);
print_r($results);
preferences:
24.82 ms | 405 KiB | 5 Q