#41785 [Opn->Bgs]: function strtr
| From: | rasmus@php.net | Date: | Sat, 23 Jun 2007 08:34:53 +0000 |
| Subject: | #41785 [Opn->Bgs]: function strtr | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-114100@lists.php.net to get a copy of this message | ||
ID: 41785
Updated by: rasmus@php.net
Reported By: saint at mail dot ntch dot edu dot tw
-Status: Open
+Status: Bogus
Bug Type: Unknown/Other Function
Operating System: CentOS5
PHP Version: 5.2.3
New Comment:
strtr works on a per-character basis. Not on entire strings like that.
The output is correct. The documentation is very clear on this:
"This function returns a copy of str, translating all occurrences of
each character in from to the corresponding character in to."
So in your case you are mapping 0554 to 0673 which doesn't actually
make any sense. You are saying that 0 becomes 0, 5 becomes 6, 5 becomes
7 and 4 becomes 3. Since you have two mappings for 5, PHP takes the
second one, so your translation table is 5->7 and 4->3. Therefore
0647;0554 becomes 0636;0773
Previous Comments:
------------------------------------------------------------------------
[2007-06-23 05:49:57] saint at mail dot ntch dot edu dot tw
Description:
------------
i hope string 0554 to 0673
print strtr( '8081;0647;0554' , '0554', '0673')
print string 8081;0637;0773
i hope string is 8081;0647;0673
print str_replace( '8081;0647;0554', '0554', '0673' );
print string 8081;0647;0673
string is right
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41785&edit=1