Answer the question
In order to leave comments, you need to log in
How to parse all images from a post?
Greetings! Prompt, $img = $pq2->find('.bbCodeImage')->attr('src');
I use this code to get image urls, $post->img = (string)$img; write to the database.
But only one url is displayed in the database, and there are several pictures in the message, tell me how to put them all in the entry in the database. Thanks to
Answer the question
In order to leave comments, you need to log in
Loop through the pictures, collect src into an array in it, and then save this data in the form you need.
$src = [];
foreach ($pq->find('.bbCodeImage') as $image) {
$src[] = pq($image)->attr('src');
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question