php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21818 strange result with strtr()
Submitted: 2003-01-22 08:53 UTC Modified: 2003-01-23 05:43 UTC
From: ldbglobe at hotmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.2.3 OS: Mandrake 8
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: ldbglobe at hotmail dot com
New email:
PHP Version: OS:

 

 [2003-01-22 08:53 UTC] ldbglobe at hotmail dot com
when i execute this expression,

echo $val=strtr('1',array('"','\"'));

i obtain the following result :

\"

infact of 1

i try to make this operation with some other number but the probl?me seems appear only with the string '1'

PS: sorry for my poor english

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-22 08:56 UTC] ldbglobe at hotmail dot com
on freeBSD I observed the same issue
 [2003-01-22 14:47 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You are not specifying the array correctly.
it should be array('#' => '\#');

Otherwise it uses numeric keys for each array element 0 for # and 1 for \#. Meaning that all 0s will be replaced with '#' and all 1s will be replaced with \#.
 [2003-01-23 05:43 UTC] ldbglobe at hotmail dot com
hu ho what a mistake
thank's
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jan 05 09:01:27 2025 UTC