How does one check string $string to see if it contains a quote """
This is what I came up with:
preg_match("/[^\"\/]/i", $value, $quoteCheck);
But doesn't seem to be right
preg_match("/\"/",$string,$quoteCheck);
Is that what you mean?
Tried that, but doesn't find anything for some odd reason.
Can you give an example of what the $string contains?
the string contains the following line:
"this is good"
with quotes on either end.
but sometimes contains
this is good
no quotes.... so it needs to know if quotes are there or not.
hi, you might try this:
$name = "\"Thomas\""; if(strstr($name, '"')){ echo "this name is not allowed"; }
I can't just give an error. If quotes exist, I need to substr() to remove the quotes from each end. If not, I don't want to cut off the text.
Then use trim():
$string = trim($string, '"');
Diego
Thanks, but can't replace all occurances.
What if there is a quote within the string itself? That needs to stay.
strchr()?
Sounds like you don't have the manual - it's an essential download.
if(preg_match('/^".*"$/s', $value) $value = substr($value,1,-1);
The s being there if there's a chance that a linebreak will appear in the string. If there's no such chance, it's unnecessary.