php.net |  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
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: hallvors at online dot no
New email:
PHP Version: OS:

 

 [2002-02-14 09:15 UTC] hallvors at online dot no
	if(isset($wrapme)){
		$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="";

becomes

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


(evident on 
http://www.hallvord.com/opera/sitetest.php?urlurl=http%3A%2F%2Fwww.excelsior.cc%2Fjs%2Fdqm_script.js&wrapme=Wrap+this+script%21&startscr=0&endscr=2265 )

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!

Patches

Pull Requests

History

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

$f=file("http://www.excelsior.cc/js/dqm_script.js");
$f=implode("", $f);
print str_replace(";", ";\n", $f);

Works as expected. The problem is not in str_replace.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC