php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47691 strtr bug. Not replace unicode values from array, in binary string.
Submitted: 2009-03-17 14:22 UTC Modified: 2015-04-13 12:50 UTC
Votes:4
Avg. Score:4.0 ± 1.0
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: strike at true-vision dot net Assigned: cmb (profile)
Status: Closed Package: Strings related
PHP Version: 6CVS-2009-03-17 (snap) OS: Fedora 8.0
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: strike at true-vision dot net
New email:
PHP Version: OS:

 

 [2009-03-17 14:22 UTC] strike at true-vision dot net
Description:
------------
Found bug in function strtr...
Not replace unicode values from array, in binary string.

Reproduce code:
---------------
<php
    $a = (binary)"AAA"; // In my code I use file_get_contents
                        // function retrun finary value
    $b = array("AAA" => "BBB");
    $c = strtr($a, $b);
    var_dump($a);
    var_dump($b);
    var_dump($c);
?>

Expected result:
----------------
string(3) "AAA" 
array(1) { [u"AAA"]=> unicode(3) "BBB" } 
string(3) "AAA" 

Actual result:
--------------
This is bug ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-18 14:09 UTC] strike at true-vision dot net
Description:
------------
Found bug in function strtr...
Not replace unicode values from array, in binary string.

Reproduce code:
---------------
<?php
    $a = (binary)"AAA"; // In my code I use file_get_contents
                        // function retrun binary value
    $b = array("AAA" => "BBB");
    $c = strtr($a, $b);
    var_dump($a);
    var_dump($b);
    var_dump($c);
?>

Expected result:
----------------
string(3) "AAA" 
array(1) { [u"AAA"]=> unicode(3) "BBB" } 
string(3) "BBB" 

Actual result:
--------------
string(3) "AAA" 
array(1) { [u"AAA"]=> unicode(3) "BBB" } 
string(3) "AAA"
 [2009-05-05 22:41 UTC] fa@php.net
Verified on Debian lenny:

(fa@debian):(~/code/src/php6) $ ~/local/php6/bin/php ~/tmp/strtr_47691.php
string(3) "AAA"
array(1) {
  [u"AAA"]=>
  unicode(3) "BBB"
}
string(3) "AAA"

Seems to be ok on FreeBSD 7.1:

(fa@freebsd):(/usr/home/fa/code/php6) $ ~/local/test/bin/php ~/tmp/strtr_47691.php
string(3) "AAA"
array(1) {
  ["AAA"]=>
  string(3) "BBB"
}
string(3) "BBB"
 [2015-04-13 12:50 UTC] cmb@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: cmb
 [2015-04-13 12:50 UTC] cmb@php.net
The development of PHP 6 has been ceased, and even in PHP 7
there'll be no Unicode strings (u"..."). In all recent official PHP
versions the test script works as expected( see
<http://3v4l.org/SXlG3>), so I'm closing the ticket.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri May 23 09:01:26 2025 UTC