Answer the question
In order to leave comments, you need to log in
How to infer style from div when parsing DOM?
<div class="_img" style="background-image: url("https://example.com/image.jpg"); width: 100%; height: 100%; max-width: 100%; max-height: 100%; border-radius: 0px;"></div>
include_once('config/phpsimple/simple_html_dom.php');
$html = file_get_html('https://example.com/index.html');
foreach($html->find('div._img') as $element) {
echo $element = $html->getAttribute('style');
}
Answer the question
In order to leave comments, you need to log in
Do just var_dump($element) like this
foreach($html->find('div._img') as $element) {
var_dump($element);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question