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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC