Pikachu2000 Posted June 19, 2010 Share Posted June 19, 2010 I have a text file that gets parsed out into an array, then is going to be dumped into a DB table. The file comes from a third party data feed. In the file, there are occasionally control characters (at least I think that's what they are) such as: ^ß that echo in the browser as the black diamond with the question mark. They are unnecessary for my purposes, and I'd like to get rid of them before inserting the data to the table. What function(s) should I be looking at for this? Link to comment https://forums.phpfreaks.com/topic/205233-stripping-out-control-characters/ Share on other sites More sharing options...
kratsg Posted June 19, 2010 Share Posted June 19, 2010 My initial guess is to try... htmlentities(). I have a feeling that it'll display fine afterwards. Link to comment https://forums.phpfreaks.com/topic/205233-stripping-out-control-characters/#findComment-1074277 Share on other sites More sharing options...
Pikachu2000 Posted June 19, 2010 Author Share Posted June 19, 2010 The thing is I don't really need them to even be there. They're wholly unnecessary for my purposes. Link to comment https://forums.phpfreaks.com/topic/205233-stripping-out-control-characters/#findComment-1074279 Share on other sites More sharing options...
kratsg Posted June 19, 2010 Share Posted June 19, 2010 Well, put it this way. I'm sure all htmlentities() come out as the form: &[stuff]; Right? After using the function, try a preg_replace with a pattern such as... $pattern = '/(&.*?;)/'; The .* is a greedy operator. Combine it with ?; to make it match everything up to the ";". It should work. Link to comment https://forums.phpfreaks.com/topic/205233-stripping-out-control-characters/#findComment-1074281 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.