Reputation: 43617
We have html page, it has many code inside.
Sometimes it has block #container
, sometimes not.
All code of this page is inside $page
variable.
How do I:
id="container"
?#container
inside, then get it contents of this block and write to a variable $container
.Task should be done by php.
Upvotes: 0
Views: 929
Reputation: 3214
One of the possible ways to solve your problem is to use third party library. Let's say http://simplehtmldom.sourceforge.net/:
$html->load($page);
if ($html->find('#container')) $container = $html->find('#container');
Upvotes: 5