Possible Duplicate:
How to parse and process HTML with PHP?
$content = "
<p>This is the first paragraph</p>
<p>This is the second paragraph</p>
<p>This is the third paragraph</p>";
Given a string of html content as above, I need to do an insert after the N'th paragraph tag.
How can I parse the content and do an insert of a given string of text, say 'hello world' after paragraph 2?