|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 09:00:02 2025 UTC |
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.