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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.