Jump to content


Photo

string replace func


  • Please log in to reply
4 replies to this topic

#1 Patrick3002

Patrick3002
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationMy Computer

Posted 13 October 2006 - 12:23 PM

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.

<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);
?>

You can view it live here: http://lyricsdbonlin.../strreplace.php
If my computer dies, it doesn't die alone.
.....I die with it.

#2 mjlogan

mjlogan
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 13 October 2006 - 12:28 PM

You were close

<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));
?>



#3 heckenschutze

heckenschutze
  • Members
  • PipPipPip
  • Advanced Member
  • 257 posts
  • LocationAustralia

Posted 13 October 2006 - 12:28 PM

<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>";
?>


#4 Patrick3002

Patrick3002
  • Members
  • PipPipPip
  • Advanced Member
  • 89 posts
  • LocationMy Computer

Posted 13 October 2006 - 12:30 PM

Ahhhh! Thank you very much! :D
If my computer dies, it doesn't die alone.
.....I die with it.

#5 mjlogan

mjlogan
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 13 October 2006 - 12:31 PM

<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>";
?>


you need to remove the
<br>
from the str_replace in that one




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users