Hey


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

I tried the following but does not work

$message = str_replace(""","",$_REQUEST['txtMessage']);
or
$message = str_replace("""","",$_REQUEST['txtMessage']);
or
$message = str_replace("\"","",$_REQUEST['txtMessage']);

Plz help

Thanx

Let's see:

<?php
function quotereplace($text) {
$text = str_replace("\"", "", $text);
return $text;
}
?>

And then:

<?php
$yourtext = 'Hello, my name is "Anders Moen" and my site is "www.andersmoen.com"';
echo quotereplace($yourtext);
?>

Does that work..?

Member Avatar for iamthwee

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.