NickAlbert Posted October 19, 2016 Share Posted October 19, 2016 $string = 'Vapes – Cookie – 3ml – 6g';$nameafter = str_replace('–','-',$string);echo $nameafter;Need it to output:Vapes - Cookie - 3ml - 6gInstead it keeps outputing:Vapes – Cookie – 3ml – 6gWhat am I missing? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted October 19, 2016 Share Posted October 19, 2016 So what's the actual goal here? To get rid of the strange looking characters in the original string? The problem is that your character encoding is messed up. The original string is encoded with UTF-8 (a multibyte Unicode encoding) and contains several Unicode dashes. But your application misinterprets the string as ISO 8859-1 data (a single byte encoding) and displays each multibyte character as a sequence of multiple nonsense characters. To fix the problem, you need to make your application use UTF-8 all the way, including the database, the database connection, the HTML document and possibly other components. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.