Answer the question
In order to leave comments, you need to log in
Errors when parsing DOMDocument, what is the reason?
There is an array like this:
$arr = array(
0 => array( 'snapshot' => '<div xmlns="http://www.w3.org/1999/xhtml" id="pages-content"><div class="image"><img src="/2019/12/1.jpg" /></div><div class="image"><img src="/2019/12/11.jpg" /></div></div>'),
1 => array( 'snapshot' => '<div xmlns="http://www.w3.org/1999/xhtml" id="pages-content"><div class="image"><img src="/2019/12/2.jpg" /></div><div class="image"><img src="/2019/12/22.jpg" /></div></div>'),
)
public function getPhotobookImages($snapshot) {
$result = array();
$dom = new DOMDocument;
$dom->loadHTML($snapshot);
$images = $dom->getElementsByTagName('img');
foreach ($images as $image) {
$result[] = $image->getAttribute('src');
}
return $result;
}
foreach($arr as $a) {
$images[] = $this->getPhotobookImages($a['snapshot'])
}
Warning: DOMDocument::loadHTML(): ID nwgrip already defined in Entity, line: 1 in (строка где: $dom->loadHTML($snapshot);)
Warning: DOMDocument::loadHTML(): ID negrip already defined in Entity, line: 1 in (строка где: $dom->loadHTML($snapshot);)
Warning: DOMDocument::loadHTML(): ID nwgrip already defined in Entity, line: 1 in (строка где: $dom->loadHTML($snapshot);)
Warning: DOMDocument::loadHTML(): ID negrip already defined in Entity, line: 1 in (строка где: $dom->loadHTML($snapshot);)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question