How to put all the images in a block of text into an array, PHP?

function has_thumbnail_image(&$post) {
    $content = $post->post_content;
    return preg_match('/<img[^>]+src="(.*?)"[^>]*>/', $content, $results);
}

I need a function that goes through a block of dynamically returned text and puts all of the images contained within into an array (or more specifically the image source of each image). The function above only gives me the first image and I cannot work out how to make this loop keep happening until all of the images are in the array. Any help on this would be much appreciated. Thanks

Related posts

Leave a Reply

3 comments