note 50739 rejected from function.str-replace by nlopess

From: Date: Tue, 08 Mar 2005 19:17:31 +0000
Subject: note 50739 rejected from function.str-replace by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86124@lists.php.net to get a copy of this message
Note Submitter: molokoloco at saintdesprit dot net ---- Hello, I search to rename a picture after uploading, with the title of a topic.... Want to replace EVERY special char. (Specialy in french, we've got a lot...) <?php function cleanName($String) { $Special = array('"', "'", '&', '€', '', '‚', 'ƒ', '„', '…', '†', '‡', 'ˆ', '‰', 'Š', '‹', 'Œ', '', 'Ž', '', '', '‘', '’', '“', '”', '•', '–', '—', '˜', '™', 'š', '›', 'œ', '', 'ž', 'Ÿ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', ';', ', ', ':', '/', '\\', '(', ')', '[', ']', '{', '}', '<', '>', '#', '@', '.', ':', '$', '€', ' ', '~', '|', '¤', '?', '!', '*', '=', '%'); $Normal = array('-', "-", 'et', 'euro', '', '-', '-', '-', '', '', '', '', '', 's', '-', 'oe', '', 'z', '', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 'oe', '', 'z', 'y', 'i', 'c', 'ls', '-', 'yen', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 'u', '', '-', '', '', '', '', '', '', '', '', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'd', 'n', 'o', 'o', 'o', 'o', 'o', 'x', '-', 'u', 'u', 'u', 'u', 'y', '', '', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'n', 'o', 'o', 'o', 'o', 'o', '', '', 'u', 'u', 'u', 'u', 'y', '', 'y', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 'at', '-', '-', 'dollar', 'euro', '-', '-', '-', '', '', '', '', '', ''); $String = trim(str_replace($Special, $Normal, strtolower($String))); return($String); } ?> Did i forget something ? Or someone have a better solution ? I also notice that in my source code some special char apear like "", but look normal in input value of the browser... Did PHP going to find them ?

« previous php.notes (#86124) next »