note 42454 added to function.str-replace

From: Date: Mon, 17 May 2004 15:07:40 +0000
Subject: note 42454 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-69719@lists.php.net to get a copy of this message
this is a rather long and obvious solution to converting non-english chars where str_replace fails. 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); } ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42454 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42454&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42454&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69719) next »