Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

html file into string

Status
Not open for further replies.

hisham

IS-IT--Management
Nov 6, 2000
194
I have an html file:
------------------------------------------
<h1>title<br>
title_one</h1>
<h3>ONE<br>
TOW<br>
THREE<br>
FOUR<br>
FIVE<br>
SIX</h3>
</body>
-------------------------------------------

I used the following code to get a text like "ONE TOW THREE FOUR FIVE SIX"

-------------------------------------------
function cleanUpHTML($text) {
$body_tags = array ("\r","\n",<h1>,<h3>,</h1>,</h3>","<br>");
$rmv_tags = array ("","","","","","","\n");
$text = str_replace ($body_tags,$rmv_tags,$text);
return ($text);
$fname = "path_to_my_file";
$whole_file = file_get_contents ($fname);
$text_pos = strpos($whole_file, '</h1>') + 5;
$text_finish = strpos($whole_file, '</body>');
$text = cleanUpHTML(substr($whole_file, $text_pos, ($text_finish - $text_pos)));
echo $text;
-------------------------------------------

but in this way I can't get the word ONE to insert it in a database.
how can I get every word into a string?
Thanks in advance.
 
From the PHP 5 help files:

(PHP 3>= 3.0.8, PHP 4 )
strip_tags -- Strip HTML and PHP tags from a string

Description
string strip_tags ( string str [, string allowable_tags])


This function tries to return a string with all HTML and PHP tags stripped from a given str. It uses the same tag stripping state machine as the fgetss() function.

You can use the optional second parameter to specify tags which should not be stripped.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top