I think there is a bug in the remove() function when called in a pq element.
try :
$content =
file_get_contents('http://www.google.fr/search?hl=fr&q=phpquery+remove');
$content = phpQuery::newDocumentHTML($content);
$logo = pq('#logo', $content);
echo (string) $logo->remove('img');
echo "\n---\n";
echo (string) $logo;
echo "\n---\n";
pq('img', $logo)->remove();
echo (string) $logo;
result :
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google<img width="167" height="222"
src="/images/srpr/nav_logo13.png" alt=""></a>
---
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google<img width="167" height="222"
src="/images/srpr/nav_logo13.png" alt=""></a>
---
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google</a>
expected result :
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google</a>
---
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google</a>
---
<a id="logo" href="http://www.google.fr/webhp?hl=fr" title="Afficher la
page d'accueil de Google">Google</a>
Original issue reported on code.google.com by xxorax on 27 May 2010 at 4:09
Original issue reported on code.google.com by
xxorax
on 27 May 2010 at 4:09