advanced_html_dom
advanced_html_dom copied to clipboard
find() can give unexpected results through its return value not being an array
Using simple_html_dom, this code:
<?php
include 'simple_html_dom.php';
$dom=str_get_html('<body><p>x</p><p>y</p></body>');
echo count(array_slice( $dom->find('p'),1,1 ));
outputs 1
http://i.imgur.com/vAADjr0.png .
But using advanced_html_dom
<?php
include 'advanced_html_dom.php';
$dom=str_get_html('<body><p>x</p><p>y</p></body>');
echo count(array_slice( $dom->find('p'),1,1 ));
it outputs 0
and the 'Warning: array_slice() expects parameter 1 to be array, object given...
'. http://i.imgur.com/85mwZ79.png
This could be a problem to anyone relying on advanced_html_dom's "The goal of this project is to be a DOM-based drop-in replacement for PHP's simple html dom library ... If you use file/str_get_html then you don't need to change anything.".