Advertisement

05.05.2008 at 10:50AM PDT, ID: 23377114 | Points: 200
[x]
Attachment Details

php count <p> tags and make changes

Asked by a2zee1979 in PHP for Windows, PHP Scripting Language, PHP and Databases

Tags:

Hello,

I have a text with a lot of html tags like <p><strong> etc

heres what i want to do:
I need to count the number of words that are in the first <p> </p>, if he words are more than or equal to 50 then I rewrite the first <p> with <p class="myClass"> if less than 50 words then the first <p> should be <p class="myClass"> AND second <p> tag should be <p class="MsoNormal myClass">

Please note that it should strip any and all other tags out from the text.

(P.S Is there any way to enter the whole question in one page on EE instead of going step by step?)

This is how far i have come:
I dont know how to catch the first <p> ... </p> block but after catching it

1.use strip_tags() to take out all inside tags (problem is, this will also take out the <p> tags  :(
2. explode() it and use count() to count the words

What do you think? Please reply with code that I can test and useStart Free Trial
 
Loading Advertisement...
 
[+][-]05.05.2008 at 10:51AM PDT, ID: 21501674

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 10:57AM PDT, ID: 21501709

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 11:06AM PDT, ID: 21501785

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 11:07AM PDT, ID: 21501799

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 12:18PM PDT, ID: 21502283

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 12:50PM PDT, ID: 21502483

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 03:55PM PDT, ID: 21503672

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.05.2008 at 04:03PM PDT, ID: 21503700

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628