Can someone please help!
I'm new to php3 and I'm still tring to find out how php3 does things I'm used to with cgi. Can someone please help me with this problem.
I need to remove any " in a text field once submitted. I don't want the user to remove it, the script should do it without the user knowing.
Therefore if this was entered.....
She said "hello"
It will change to.....
She said hello
Thanks
Steve
$inputfieldname = ereg_replace(""", " ", $inputfieldname);
for PERL syle reg exp: http://www.php.net/manual/ref.pcre.php
The same without ereg:
$inputfieldname=implode("",explode("\"",$text));
JBL
Thanks, but nether of these work!
It leaves a backslash \ where there was a ".
Any other ideas???
Thanks!
if the "She said..." line is in $line:
$line = ereg_replace("\"", "", $line);
That's all 🙂
--Ryan
It doesn't want to work.....
If the input is....
She said "hello".
after passing through
it returns....
She said \hello.
Thanks Steve
Works for me, here's my test code:
<? $line = 'She said "hello"'; $line = ereg_replace("\"", "", $line); echo("$line\n"); ?>
[ryan@score ryan]$ php -q test.php She said hello [ryan@score ryan]$
Did the string comes from a text field ?
if so php quote the string with \
use 'stripslashes' function to strip slashes before removing the ". Then either ereg or implode/explode method will work
Thanks.... thats sorted out my problem.
I've also combined it all into one line....
$input = ereg_replace("\"", "", stripslashes ($input));
Thanks again.... it works a treat.