|
Posted by pangea33 on 12/15/06 06:56
veg_all@yahoo.com wrote:
> I replace some user input with their ascii equivalent so they display
> on the webpage properly:
>
> $entry = preg_replace ( "/\'+/" , ''' , $entry);
> $entry = preg_replace ( "/\,+/" , ',' , $entry);
>
> I then need to email the data, however in email the ascii code is
> displayed, not the text.
> Is there an easier way to convert the ascii back to the text without
> another preg_replace?
There really doesn't seem to be any reason you have to manually escape
the string with a regular expression, then change it back. Especially
since you're only accounting for a small set of characters that might
have problems. Why not leave the variable exactly as entered by the
user, and just run it through the "htmlspecialchars()" function when
you want to display it on the page?
http://us2.php.net/manual/en/function.htmlspecialchars.php
Navigation:
[Reply to this message]
|