Need help removing something from text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Need help removing something from text file

Post by Extremest »

I have a big text file with a bunch of words in it for my db. Problem is somehow it got some squares in the text from one of the files. I have copied the square itself and put it in my replace array but yet it don't get removed. Was wondering if anyone knows what it is. I tried removing \r thinking maybe that was it but was wrong. Help is definately needed.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

they are likely binary characters outside the character set of the font you are using.
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post by Extremest »

Is there anyway to get rid of them? If I do a replace with them to a space and save the file they come right back. I don't quite understand that.
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post by Extremest »

ok It might be the extended chars from 128 up. I noticed a few of them in there from that block. Now using preg_replace how do I setup and array to for the search for those. I am not sure how I have to setup the expression. I have been using str_replace.
Extremest
Forum Commoner
Posts: 84
Joined: Mon Aug 29, 2005 12:39 pm

Post by Extremest »

ok I think I have it now using this.

Code: Select all

$new_data = ereg_replace("[^A-Za-z0-9]", "", $data);
Post Reply