php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #51908 Undocumented return value for strtr
Submitted: 2010-05-25 21:14 UTC Modified: 2010-05-28 18:02 UTC
From: tsteiner at nerdclub dot net Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.2 OS: Any
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: tsteiner at nerdclub dot net
New email:
PHP Version: OS:

 

 [2010-05-25 21:14 UTC] tsteiner at nerdclub dot net
Description:
------------
If strtr(string $str, array $replace_pairs) is called and one of the keys of $replace_pairs is an empty string, strtr will return the boolean value FALSE.  This is not reflected in the documentation.

Test script:
---------------
<?php
var_dump(strtr('foo', array('' => 'nothing')));

Expected result:
----------------
Unsure, is the empty string ever really "found" in a string?

Actual result:
--------------
bool(false)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-05-28 17:50 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=299913
Log: tidied up return values section for strtr()
  - simpler normal return value description
  - empty key returns false (bug #51908)
 [2010-05-28 18:02 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2010-05-28 18:02 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

I've added a note about the function returning false when an empty string key is 
provided. Thanks for the report!
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 08:00:01 2026 UTC