Jump to content

Archived

This topic is now archived and is closed to further replies.

Patrick3002

string replace func

Recommended Posts

Hi, im editing a file which would take forever to edit with out a program. I have created one for different stuff but im stuck on this....

I need to be able to insert numerous lines like:

DEL  "c:\windows\servicepackfiles\i386\adv11nt5.dll"
DEL  "c:\windows\servicepackfiles\i386\advapi32.dll"
DEL  "c:\windows\servicepackfiles\i386\advpack.dll"
DEL  "c:\windows\servicepackfiles\i386\aec.sys"
DEL  "c:\windows\servicepackfiles\i386\afd.sys"
DEL  "c:\windows\servicepackfiles\i386\agentanm.dll"
DEL  "c:\windows\servicepackfiles\i386\agentctl.dll"

into a textarea and then hit a submit button and have them come out like:

DEL  "f:\windows\servicepackfiles\i386\adv11nt5.dll"
DEL  "f:\windows\servicepackfiles\i386\advapi32.dll"
DEL  "f:\windows\servicepackfiles\i386\advpack.dll"
DEL  "f:\windows\servicepackfiles\i386\aec.sys"
DEL  "f:\windows\servicepackfiles\i386\afd.sys"
DEL  "f:\windows\servicepackfiles\i386\agentanm.dll"
DEL  "f:\windows\servicepackfiles\i386\agentctl.dll"

notice the c: changes to f:

I need it to display just like that too, each one on a different line.

Here is my current program i am not sure how to edit this to work with those " etc.

[code]<form name="strreplace" action="strreplace.php" method="post">
<textarea name="main" cols="50" rows="40" wrap="VIRTUAL" id="main"></textarea>
<input type="submit" value="Submit">
</form>
<?
$main=$_POST['main'];
$main = str_replace("c:","<br>f:","$main");

echo stripslashes($main);
?>
[/code]

You can view it live here: [url=http://lyricsdbonline.com/strreplace.php]http://lyricsdbonline.com/strreplace.php[/url]

Share this post


Link to post
Share on other sites
You were close

[code=php:0]
<form name="strreplace" action="strreplace.php" method="post">
<textarea name="main" cols="50" rows="40" wrap="VIRTUAL" id="main"></textarea>
<input type="submit" value="Submit">
</form>
<?
$main=$_POST['main'];
$main = str_replace("c:","f:","$main");

echo nl2br(stripslashes($main));
?>

[/code]

Share this post


Link to post
Share on other sites
[code]<form name="strreplace" action="strreplace.php" method="post">
<textarea name="main" cols="50" rows="40" wrap="VIRTUAL" id="main"></textarea>
<input type="submit" value="Submit">
</form>
<?
$main=$_POST['main'];
$main = str_replace("c:","<br>f:","$main");

echo "<pre>";
echo stripslashes($main);
echo "</pre>";
?>[/code]

Share this post


Link to post
Share on other sites
[quote author=heckenschutze link=topic=111385.msg451341#msg451341 date=1160742498]
[code]<form name="strreplace" action="strreplace.php" method="post">
<textarea name="main" cols="50" rows="40" wrap="VIRTUAL" id="main"></textarea>
<input type="submit" value="Submit">
</form>
<?
$main=$_POST['main'];
$main = str_replace("c:","<br>f:","$main");

echo "<pre>";
echo stripslashes($main);
echo "</pre>";
?>[/code]
[/quote]

you need to remove the [code]<br>[/code] from the str_replace in that one

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.