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

i have a quick preg_match question 1

Status
Not open for further replies.

pushyr

Programmer
Jul 2, 2007
159
GB
For the following code, how would i use regex (preg_match) to match the just the 2nd paragraph, or the 3rd, and so on?

Code:
<p>1st paragraph of text here</p>
<p>2nd paragraph of text here</p>
<p>3rd paragraph of text here</p>


 
Hi

Code:
$str="<p>1st paragraph of text here</p>
<p>2nd paragraph of text here</p>
<p>3rd paragraph of text here</p>";

[url=http://php.net/preg_match_all/]preg_match_all[/url](",<p>.*?</p>,",$str,$match);

echo $match[0][1]; [gray]// prints "<p>2nd paragraph of text here</p>"[/gray]

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top