note 39411 deleted from function.strtoupper by derick
| From: | derick@php.net | Date: | Tue, 30 Aug 2005 11:06:47 +0000 |
| Subject: | note 39411 deleted from function.strtoupper by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94396@lists.php.net to get a copy of this message | ||
Note Submitter: Ansis [ataols in latnet point lv]
----
In the case transformations it is better to use "preg_replace", not "strtr":
1) it is faster;
2) it is possible to write a transformation formula for all Windows codepages, instead of each
letter writing as most of you did.
Thus, for "to upper case" transformation:
<?php
$result =
preg_replace("/([a-z\xE0-\xFF])/e","chr(ord('\\1')-32)",$arg);
?>
For "to lower case" transformation:
<?php
$result =
preg_replace("/([A-Z\xC0-\xDF])/e","chr(ord('\\1')+32)",$arg);
?>