A question related on my previous post, about Simple HTML DOM Parser. This is my html code:
<div id="header">
<h1>Hello World!</h1>
</div>
<div id="container">
<div id="content">
<p> </p>
</div>
</div>
<div id="footer">
<p>LINK HERE</p>
</div>
I want to insert a link on the <p>
of the footer.I could insert a link but the problem is, if there is another <p>
before the div footer's <p>
, the link will be inserted at the <p>
in the html code. It's like it can't identify or it cannot be detected that it SHOULD ONLY SEARCH IN THE div id=footer, not the whole html code.
Here's what i've got:
foreach($html->find('div#footer') as $footer)
{
foreach($footer->find('p') as $p)
{
$footerInnerText = $p->find('p', 0)->innertext;
$theLink = '<a href="index.php" title="" rel="home">'. $footerInnerText. '</a>';
$html->find('p', 0)->innertext = "\n" .$theLink."\n";
}
I have also tried this:
$e = $html->find('div#footer', 0)->find('p', 0);
What am i missing here?
).*(
).*()/" – Flying Swissman Jan 26 '11 at 06:56` for HTML? – Matt Gibson Jan 26 '11 at 10:38