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? Link to comment https://forums.phpfreaks.com/topic/195997-str_replace-not-matching-some-characters/ 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 Link to comment https://forums.phpfreaks.com/topic/195997-str_replace-not-matching-some-characters/#findComment-1029521 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. Link to comment https://forums.phpfreaks.com/topic/195997-str_replace-not-matching-some-characters/#findComment-1029647 Share on other sites More sharing options...
devofash Posted March 21, 2010 Share Posted March 21, 2010 Try using preg_replace instead. Link to comment https://forums.phpfreaks.com/topic/195997-str_replace-not-matching-some-characters/#findComment-1029649 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.