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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.)