note 42454 deleted from function.str-replace by bjori

From: Date: Sun, 26 Mar 2006 22:28:07 +0000
Subject: note 42454 deleted from function.str-replace by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106683@lists.php.net to get a copy of this message
Note Submitter: bookvii at hotmail dot com ---- this is a rather long and obvious solution to converting non-english chars where str_replace fails. <?php function euro_chars($str) { $tmp = ""; for($i = 0; $i < strlen($str); $i++) { switch(ord($str[$i])) { case 192: case 193: //À Á $tmp .= "A"; break; case 200: case 201: //È É $tmp .= "E"; break; case 204: case 205: //Ì Í $tmp .= "I"; break; case 210: case 211: //Ò Ó $tmp .= "O"; break; case 217: case 218: //Ù Ú $tmp .= "U"; break; case 224: case 225: //à á $tmp .= "a"; break; case 232: case 233: //è é $tmp .= "e"; break; case 236: case 237: //ì í $tmp .= "i"; break; case 242: case 243: //ò ó $tmp .= "o"; break; case 249: case 250: //ù ú $tmp .= "u"; break; case 241: //ñ $tmp .= "n"; break; case 209: //Ñ $tmp .= "N"; break; case 231: //ç $tmp .= "c"; break; case 199: //Ç $tmp .= "C"; break; case 128: //€ $tmp .= "EU"; break; default: $tmp .= (string)$str[$i]; break; } } return($tmp); } ?>

« previous php.notes (#106683) next »