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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulating texts that contain HTML tags

Status
Not open for further replies.

elck

Programmer
Apr 19, 2004
176
NL
Hello,

I'm trying to write automated page-makeup and therefore I need to be able to count the number of words in a text that countains html tags.

I want to split up the text into columns, but, suppose the break occurs in the middle of '<b>this ^ bold tekst</b>', then I would run the risk of having a large part of the page in bold if I forgot the put a closing </b> after 'this'

That's just one problem.
I am not asking you to write this for me, I just wonder if someone has done work on this before and can give me some hints.



 
I know how to write this in perl, maybe someone here can translate it to php. Put the html content into $page

$page = split(/>/,$page);
#Then with regex
foreach(@page){s/<.*//;}
$page = join(' ',@page);
@page = split(/\s*/,$page);

not tested, but it's a start.
I'm just learning php and am sure there is a similar functionality. Vooala! you should have the word count.

Thanks
Tricia
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top