|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27457 Problem with strtr() and translation array
Submitted: 2004-03-02 03:40 UTC Modified: 2004-03-18 05:31 UTC
From: solace at ezmail dot ru Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2004-03-09 OS: *
Private report: No CVE-ID: None
 [2004-03-02 03:40 UTC] solace at ezmail dot ru
I wanted to test compatibility of my scripts with the latest php5 beta and discovered very strange results.
Well, something is wrong with strtr() function working with translation array. It worked fine with php 4.x.x.
But strtr() with strings still works.

I'm using command-line php.exe with -n switch, without php.ini or any modules.

Reproduce code:
$test = "Dot in brackets [.]\n";
$test = strtr($test, array('.' => '0'));

// doesn't work ???
$test = strtr($test, array('0' => '.'));
echo $test;

// but this works!!!
$test = strtr($test, '0', '.');
echo $test;

Expected result:
Dot in brackets [.]

Actual result:
Dot in brackets [0]


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-02 04:12 UTC]
Recategorize bug.
 [2004-03-18 05:31 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Dec 03 20:01:28 2023 UTC