hey ya,
I have some text that contains " and ' symbols,
since I'd like to process these files as strings, I need to add a \ before with addslashes, but when I try to do so, I need to define the string, which doesn't work, since parts of the text are ignored or I get some parse-errors
you know how to solve that problem??
string help
Moderator: General Moderators
Strip em
Hey,
Since u add the slashes, U can reverse it juz before u want to use the string.
Since u add the slashes, U can reverse it juz before u want to use the string.
Code: Select all
stripslashes();Well,
I played around a little and come to the conclusion after reading the documentation
that it would seem to be easyier to just add the slashes around the symbols in the string...
and then strip them
I played around a little and come to the conclusion after reading the documentation
that it would seem to be easyier to just add the slashes around the symbols in the string...
and then strip them
Code: Select all
<?PHP
$string= "I had dinner at'her mumas' house it was "quite"";
$stripped= stripslashes($string);
echo "$string";
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
You won't get a parse error on this because the string is in double quotes and that single quote will be ignored. This:moehome wrote:"I ate at my mother's"- will get a parse error
Code: Select all
echo 'I ate at my mother's';Where are you getting the data from? If it's coming from a form slashes are automagically added where needed. If it's coming from a flat file or a database you could addslashes as you read the data out of it. If you're typing the strings in by hand you might as well add the slashes as you do it, AFAIK there's really no way around that except by maybe adding two single quotes ('') and then using str_replace to change those to escaped double quotes (").
Everybody's only trying to help.
Mac