note 33625 added to function.str-replace
| From: | kerxen at caramail dot com | Date: | Wed, 02 Jul 2003 09:02:54 +0000 |
| Subject: | note 33625 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51340@lists.php.net to get a copy of this message | ||
Here is a version of the CONVERSION "TO LOWER" and "TO UPPER" CASE.
I post it because I saw some functions that don't work.
At first, we replace the special charactères.
Then we use the basic PHP functions like strToUpper and strToLower.
function toUpper ($text) {
$lower = array
('à','á','â','ã','ä','å','æ','ç',
'è','é','ê','ë','ì','í','î','ï',
'ð','ñ','ò','ó','ô','õ','ö','÷'
,'ø','ù','ü','ú','þ','ÿ');
$upper = array
('À','Á','Â','Ã','Ä','Å','Æ','Ç',
'È','É','Ê','Ë','Ì','Í','Î','Ï',
'Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×'
,'Ø','Ù','Ü','Ú','Þ','ß');
$text = str_replace($lower, $upper,$text);
return strToUpper($text);
}
function toLower ($text) {
$lower = array
('à','á','â','ã','ä','å','æ','ç'
,'è','é','ê','ë','ì','í','î','ï',
'ð','ñ','ò','ó','ô','õ','ö',
'÷','ø','ù','ü','ú','þ','ÿ');
$upper = array
('À','Á','Â','Ã','Ä','Å','Æ','Ç'
,'È','É','Ê','Ë','Ì','Í','Î','Ï',
'Ð','Ñ','Ò','Ó','Ô','Õ','Ö',
'×','Ø','Ù','Ü','Ú','Þ','ß');
$text = str_replace($upper,$lower, $text);
return strToLower($text);
}
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33625
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33625&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33625&report=yes