I am trying to replace £
with £
and it did not work.
I've tried:
echo str_replace("£", "£", "£3 Discount Discount");
I have also tried html_entity_decode
which also did not work.
I am trying to replace £
with £
and it did not work.
I've tried:
echo str_replace("£", "£", "£3 Discount Discount");
I have also tried html_entity_decode
which also did not work.
This is an issue with trying to display UTF-8–encoded data as non–UTF-8. You need to make sure that all character encodings are consistent, and if not then you're converting between them appropriately. The easiest way is to ensure that absolutely everything is in UTF-8. This includes:
SET NAMES UTF-8
)header('Content-Type: text/html; charset=utf-8');
)I would first suggest checking that there isn't any mojibake in your database (e.g. using phpMyAdmin or command-line client), before checking the character sets above. If you find that the database actually contains £
, then I would suggest applying the same logic above to any input mechanism to the database (including character encoding of HTML forms).
(Note: I've assumed MySQL throughout this answer.)