Rykin Posted March 21, 2010 Share Posted March 21, 2010 I am using str_replace() to clean up some data I am getting from another source and it is working just fine in some instances but not at all in others. For instance it isn't replacing … or ‘ or ’ or a number of other characters. I am feeding str_replace two arrays, one with the characters/strings to replace and another with the characters/strings to replace them with. Any ideas why it would be replacing some characters just fine but not others? Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted March 21, 2010 Share Posted March 21, 2010 It sounds like it's a problem with multibyte strings. Take a look here http://stackoverflow.com/questions/1451144/php-multi-byte-str-replace Quote Link to comment Share on other sites More sharing options...
Rykin Posted March 21, 2010 Author Share Posted March 21, 2010 Tried using that mb_str_replace function from that thread but it just returned a bunch of warnings and didn't work. Sounds like this is an issue with str_replace though so I guess I will just write a function that uses preg_replace for all the strings/characters that str_replace has issues with. Quote Link to comment Share on other sites More sharing options...
devofash Posted March 21, 2010 Share Posted March 21, 2010 Try using preg_replace instead. 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.