php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43766 Arrays and inverted commas
Submitted: 2008-01-06 06:38 UTC Modified: 2008-01-07 14:57 UTC
From: quick dot webmaster at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.5 OS: Linux
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: quick dot webmaster at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-06 06:38 UTC] quick dot webmaster at gmail dot com
Description:
------------
Hello, if you try to insert a " immediately before a ' in an array then it will return strange results results.

Reproduce code:
---------------
<?php

$image[0] = array('<img src="http://bugs.php.net/gifs/logo-bug.gif" />');

$trans4 = array('<img src="' => '', '" />' => '');
$image2 = strtr($image[0], $trans4);

?>

Expected result:
----------------
http://bugs.php.net/gifs/logo-bug.gif

Actual result:
--------------
http://bugs.php.net/gifs/logo-bug.gif"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-06 11:41 UTC] felipe@php.net
Your code is wrong, it is attempt to pass array as first argument.

I'm using PHP5.3, and the code below works fine. So, try:

<?php

$image = '<img src="http://bugs.php.net/gifs/logo-bug.gif" />';

$trans4 = array('<img src="' => '', '" />' => '');

var_dump(strtr($image, $trans4));
// string(37) "http://bugs.php.net/gifs/logo-bug.gif"

?>
 [2008-01-07 14:57 UTC] iliaa@php.net
see above comment.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 09:01:34 2025 UTC