I
I
Ilya19882019-05-20 19:52:53
PHP
Ilya1988, 2019-05-20 19:52:53

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

1 answer(s)
I
Ilya Loginov, 2019-05-20
@Ilya1988

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 question

Ask a Question

731 491 924 answers to any question