extract text from html-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
torvald_helmer
Forum Newbie
Posts: 4
Joined: Sun Nov 26, 2006 6:51 am

extract text from html-file

Post by torvald_helmer »

I have a html-file, which I want to extract the some content, and not any tag's.

I thought I might start like this:
$file = file("test.html");
foreach ($file as $line) {

some code....

}

A example is this line is the file:
<tr><td class="felt">Car</td><td>Mercedes<br/></td></tr>

How can I get just 'Car' and 'Mercedes' from this line?

Has anyone got an idea? I really don't know where to go further...
Need help!
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Regular expressions. This has been asked around here before. Try searching these forums for 'scraping' or some combination of 'getting content from web page'.
Post Reply