note 42383 deleted from function.strtoupper by nlopess
| From: | nlopess@php.net | Date: | Sun, 20 May 2007 13:41:57 +0000 |
| Subject: | note 42383 deleted from function.strtoupper by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126730@lists.php.net to get a copy of this message | ||
Note Submitter: Luke (webmaster--@--zeyus--dot--com)
----
Just a comment on Jose Roberto Kerne's script (which should work perfectly), it should be able
to be cut down to this, as str_replace accepts array values (as of ??? php version), the only
difference is this should be quicker and obviously array values could be replaced with any
characters (or sets of strings) you want to be replaced
<?php
function stringUpDown($text, $up = true){
# Convert values from Lower to Upper
$arrayLower=array('ç'
,'â','ã','à','á','ä'
,'é','è','ê','ë'
,'í','ì','î','ï'
,'ó','ò','ô','õ','ö'
,'ú','ù','û','ü');
$arrayUpper=array('Ç'
,'Â','Ã','Á','À','Ä'
,'É','È','Ê','Ë'
,'Í','Ì','Î','Ï'
,'Ó','Ò','Õ','Ô','Ö'
,'Ú','Ù','Û','Ü');
if($text == ''){
return $text;
}
if($up != true) {
$text=strtolower($text);
$text=str_replace($arrayUpper, $arrayLower, $text);
}else{
$text=strtoupper($text);
$text=str_replace($arrayLower, $arrayUpper, $text);
}
return($text);
} #end of function
?>