Here, hopefully this explains it better:
Basically I have a php page that displays my articles, and just need
to do an ereg_replace that replaces the third instance of a <p> tag
with the <p> tag plus a table so I can insert a table column that's
aligned left, with the remaining story wrapping around it.
The full body of the story is in a variable $body, that when echoed
outputs the article.
Example: (If I was replacing all of them)
$output =
ereg_replace("<p>","<p><table width=180 cellpadding=0 cellspacing=10
border=1 align=left><tr><td>Cell contents</td></tr></table>", $body);
I just can't figure out how to replace the third instance of that <p>
tag.
Example:
First paragraph with a bunch of words.
<p>
Second paragraph with a bunch of words.
<p>
Third paragraph with a bunch of words.
<p>
Fourth paragraph with a bunch of words along with the rest of the article.
To be replaced with:
First paragraph with a bunch of words.
<p>
Second paragraph with a bunch of words.
<p>
Third paragraph with a bunch of words.
<p>
<table width=180 cellpadding=0 cellspacing=10 border=1
align=left><tr><td>Cell contents</td></tr></table>
Fourth paragraph with a bunch of words along with the rest of the article.
Make sense? Obviously there are more <p> tags in between paragraphs after this point depending on the length of the article, but I'm just looking to do a single replacement on the third instance of it.
Thanks in advance for your assistance!
Ian