|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15552 str_replace with semicolons finds other characters as well
Submitted: 2002-02-14 09:15 UTC Modified: 2002-02-14 09:54 UTC
From: hallvors at online dot no Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.0.6 OS: SunOS no14 / Linux merlin 2.4.2
Private report: No CVE-ID: None
 [2002-02-14 09:15 UTC] hallvors at online dot no
		$thescript=str_replace(";", ";\n", $thescript);

This is my solution when trying to wade through horribly compact "all-on-one-line" style JavaScript: $thescript is read from the JS-URL with fopen() and I'm trying to wrap it on semicolons. Result:

var q22="";var q23="";


var q22="
var q23="

(evident on )

Have I misunderstood something here or is it a bug that str_replace with ';' as search also finds "" ? Tried preg_replace with the same result, even when given a \x hex code input. Reproduced on two different versions of PHP (most recent being 4.0.6 but I'm not in charge of upgrading the servers so I can't test it in later builds) and two different server setups.

I hope this is a genuine bug - if not I'm sorry!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-14 09:54 UTC]
I cannot reproduce this. I tried to following code snippet:

$f=implode("", $f);
print str_replace(";", ";\n", $f);

Works as expected. The problem is not in str_replace.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Nov 30 20:01:26 2023 UTC