Replace "

Reply

Join Date: Dec 2004
Posts: 234
Reputation: cancer10 is an unknown quantity at this point 
Solved Threads: 0
cancer10's Avatar
cancer10 cancer10 is offline Offline
Posting Whiz in Training

Replace "

 
0
  #1
Jun 9th, 2007
Hey


Does anyone knows how do I replace a " (double quote) in a string with nothing

I tried the following but does not work

  1. $message = str_replace(""","",$_REQUEST['txtMessage']);
  2. or
  3. $message = str_replace("""","",$_REQUEST['txtMessage']);
  4. or
  5. $message = str_replace("\"","",$_REQUEST['txtMessage']);


Plz help

Thanx
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 14
Reputation: Andy-Pandy is an unknown quantity at this point 
Solved Threads: 0
Andy-Pandy Andy-Pandy is offline Offline
Newbie Poster

Re: Replace "

 
0
  #2
Jun 9th, 2007
Let's see:

  1. <?php
  2. function quotereplace($text) {
  3. $text = str_replace("\"", "", $text);
  4. return $text;
  5. }
  6. ?>

And then:
  1. <?php
  2. $yourtext = 'Hello, my name is "Anders Moen" and my site is "www.andersmoen.com"';
  3. echo quotereplace($yourtext);
  4. ?>

Does that work..?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Replace "

 
0
  #3
Jun 9th, 2007
Yes, basically you have to use an escape character for it to recognise the quote, which is a backward slash. For more complex parsing check out the regex libraries.
Last edited by iamthwee; Jun 9th, 2007 at 10:46 am.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC