Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Solution 1
- $inistring = "Peut être à 100€ ou à 100$ ou 68£, ça ne fonctionne \n pas ^^";
- $string = preg_replace(array('@\pM@u', '/^(.)/ue', '/\s+(.)/ue'), array('', 'lcfirst(\'\\1\')', 'ucfirst(\'\\1\')'), \normalizer::normalize(trim($inistring), Normalizer::FORM_D));
- var_dump($string);
- // Solution 2
- $string = lcfirst(preg_replace('/[\s\'^`,]+/u', '', ucwords(strtolower(iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', trim($inistring))))));
- var_dump($string);
- // Solution 3
- $s = preg_replace('/\s+/u', ' ', $inistring);
- $s = trim($s);
- if ('' !== $s)
- {
- // UTF-8 to ASCII transliteration
- if (preg_match("'[\x80-\xFF]'", $s))
- {
- $s = Normalizer::normalize($s, Normalizer::FORM_KD);
- $s = preg_replace('/\p{Mn}+/u', '', $s);
- $s = iconv('UTF-8', 'ASCII' . ('glibc' !== ICONV_IMPL ? '//IGNORE' : '') . '//TRANSLIT', $s);
- }
- // Camel-case
- $s = strtolower($s);
- $s = ucwords($s);
- $s[0] = strtolower($s[0]);
- // Remove spaces
- $s = str_replace(' ', '', $s);
- }
- var_dump($s);
- // Résultats :
- // string(48) "peutEtreA100€OuA100$Ou68£,CaNeFonctionnePas^^"
- // string(45) "peutetrea100eurOua100$Ou68lbCaNeFonctionnePas"
- // string(48) "peutEtreA100eurOuA100$Ou68lb,CaNeFonctionnePas^^"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement