php.net |  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
Description:
------------
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]

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-02 04:12 UTC] derick@php.net
Recategorize bug.
 [2004-03-18 05:31 UTC] derick@php.net
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
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC