Jump to content

string replace func


Patrick3002

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]
Link to comment
https://forums.phpfreaks.com/topic/23842-string-replace-func/
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]
Link to comment
https://forums.phpfreaks.com/topic/23842-string-replace-func/#findComment-108291
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]
Link to comment
https://forums.phpfreaks.com/topic/23842-string-replace-func/#findComment-108292
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
Link to comment
https://forums.phpfreaks.com/topic/23842-string-replace-func/#findComment-108294
Share on other sites

Archived

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

×
×
  • Create New...

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.