i need replace & ©
and another &******;
and replace it to ""
preg_replace or ereg_replace, i need some code
tried
$string = "one two&three©four";
$r = preg_replace('/^&+(\w)+;/', '--', $string);
echo $r;
it's incorrect
Drop the initial ^
. You want to match anywhere in the string, not just the start of the string.
preg_replace('/&+(\w)+;/', '--', $string);
→ string(21) "one--two--three--four"
To be more precise, this:
preg_replace('/&#?+(\w)+;/', '--', $string);
will cut out also numeric codes like ¢
and ¢
.