|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25632 str_replace incorrect
Submitted: 2003-09-23 07:01 UTC Modified: 2003-09-23 07:35 UTC
From: info at comsen dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.1 OS: Apache httpd 1.3.26
Private report: No CVE-ID: None
 [2003-09-23 07:01 UTC] info at comsen dot de
I have a text with placeholders for images: ##-1 -> img No 1 ##-2 img No 2 etc.

It works fine with the reproduce code as long as the number is a single digit:

with numbers higher then 9 the image will be shown followed by the last digit.

Is it a bug?

Reproduce code:
$text "abc def ##-23 yxz";

$pic = "<img src = 'img-23'>";

$text_new = str_replace(*##-'.$pic, $image, $text);

Expected result:
(image shown)

Actual result:
(image shown)3


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-23 07:35 UTC]
1. Too old PHP version (we're at 4.3.3 already)
2. Your example script has 2 parse errors for you propably want to use preg_replace() anyway.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Sep 28 09:01:25 2020 UTC