cahamilton Posted April 20, 2009 Share Posted April 20, 2009 Does anyone know of a function or script that would help me convert special characters such as ê and á to normal characters (e and a)? Rather than str_replace'ing them all, is there a function I can just wrap around my variable to escape and convert all the misc characters? Quote Link to comment https://forums.phpfreaks.com/topic/154939-solved-sp%C3%A9ci%C3%A1l-charact%C3%AArs/ Share on other sites More sharing options...
premiso Posted April 20, 2009 Share Posted April 20, 2009 I believe you would have to setup a str_replace have an array of special characters then another array of their counter parts (the indexes must match for what you want replaced). I do not know of any function that will do it, but you may be able to find one via google that someone else had made. Quote Link to comment https://forums.phpfreaks.com/topic/154939-solved-sp%C3%A9ci%C3%A1l-charact%C3%AArs/#findComment-814982 Share on other sites More sharing options...
cahamilton Posted April 20, 2009 Author Share Posted April 20, 2009 Aha, thanks for your help. Just been pointed in the right direction from one of my friends. Anyone that's interested, this has worked for me: <?php function normaliza ($string){ $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ ßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿŔŕ'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuy bsaaaaaaaceeeeiiiidnoooooouuuyybyRr'; $string = utf8_decode($string); $string = strtr($string, utf8_decode($a), $b); $string = strtolower($string); return utf8_encode($string); } ?> from here: http://uk.php.net/strtr Cheers premiso Quote Link to comment https://forums.phpfreaks.com/topic/154939-solved-sp%C3%A9ci%C3%A1l-charact%C3%AArs/#findComment-814994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.