I want to use PHP & QueryPath to find all images in a document, then modify its src
like this:
I want to change
http://test.com/test/name.jpg
to
http://example.com/xxx/name.jpg
I can find the specific class name using
$qp2 = $qp->find('body');
Now when I want to find all img
on it to change the src
:
foreach ($qp2->find('img') as $i) {
//here change the src
}
But when I execute
echo $qp2->html();
I see only last image. Where is the problem?
Like this?
Sometimes you have to use top() or end() when you are re-using the qp object. Something like:
$qp = htmlqp($lpurl);