Page 1 of 1

&#982 strip these?

Posted: Sat Jul 22, 2006 3:09 pm
by jasondavis
How can I strip things like &#982 out of a variable, Im not sure what they are called but hteres like 100's of them

Posted: Sat Jul 22, 2006 3:12 pm
by RobertGonzalez
Those are HTML entities (or sometimes refered to as ASCII characters, though I was told that was not the correct name for them). Do you want to get rid of them altogether? If so, use

Code: Select all

str_replace()
.

Posted: Sat Jul 22, 2006 3:34 pm
by jasondavis
using that how could i remove "&"

Posted: Sat Jul 22, 2006 3:34 pm
by RobertGonzalez
Have you read the manual page I refered you to? It gives examples. Try one. If it doesn't work, post back.

Posted: Sat Jul 22, 2006 4:12 pm
by Chris Corbyn

Code: Select all

$string = preg_replace('/&#\d+;/', '', $string);
Using str_replace() could be better though. Just str_replace all & to &

Posted: Sat Jul 22, 2006 4:35 pm
by RobertGonzalez
str_ functions are faster than preg_ functions. But if this is not a high volume app, or you need the flexibility of regular expression matching, use the preg_ functions.