943,993 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1049
  • PHP RSS
Jun 9th, 2007
0

Replace "

Expand Post »
Hey


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

I tried the following but does not work

PHP Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 58
Solved Threads: 1
Posting Whiz in Training
cancer10 is offline Offline
234 posts
since Dec 2004
Jun 9th, 2007
0

Re: Replace "

Let's see:

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

And then:
PHP Syntax (Toggle Plain Text)
  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..?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Andy-Pandy is offline Offline
14 posts
since Oct 2006
Jun 9th, 2007
0

Re: Replace "

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.
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Web form
Next Thread in PHP Forum Timeline: PHP and MySQL





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC