From this Simple Dom Site
if(isset($html->'div#sidebar'))
{
$sidebarFile = 'D:\xampp\htdocs\final\wordpress\sidebar.php';
$openSidebarFile = fopen($sidebarFile,'a');
foreach($html->find('div#sidebar')) as $e)
{
$html ->find('div[id=sidebar]', 0) -> innertext;
$inputSidebar = $e->outertext;
fwrite($openSidebarFile, "\n" .inputSidebar "\n");
}
}
From the documentation:
it says:
// Determine whether a attribute exist?
if(isset($e->href))
echo 'href exist!';
There are a few issues here I’ll just correct them inline:
Now, what was changed? The first
if, and theforeach. The if used the wrong function, and the wrong check for empty. The foreach had mismatched()braces.