I am looking to get all images from the Wordpress publish to produce a slideshow from their store. Researched around and located this bit of code to retrieve and display images from the publish:

function getImage($num) {
    global $more;
    $more = 1;
    $link = get_permalink();
    $content = get_the_content();
    $count = substr_count($content, '<img');
    $start = 0;
    for($i=1;$i<=$count;$i++) {
        $imgBeg = strpos($content, '<img', $start);
        $post = substr($content, $imgBeg);
        $imgEnd = strpos($post, '>');
        $postOutput = substr($post, 0, $imgEnd+1);
        $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
        $image[$i] = $postOutput;
        $start=$imgEnd+1;
    }
    if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
    $more = 0;
}

Understandably after this you use getImage('1') etc. to obtain first, second images in the publish etc. This is not ideal to produce a slideshow, because I'm not sure the number of image maybe there is.

It is possible to method to customize the code above to obtain a range of images to make use of to produce a foreach loop, for instance? Sorry if my logic is a little problematic, I am not really a PHP expert, as you may have suspected.

Thanks ahead of time for just about any help.

This code has already been finding all of the images, but is just making 1.

Do this variation, that ought to echo all images rather than just 1. I've not examined this, but when you original code labored, this will.

function getImage() {
    global $more;
    $more = 1;
    $link = get_permalink();
    $content = get_the_content();
    $count = substr_count($content, '<img');
    $start = 0;
    for($i=1;$i<=$count;$i++) {
        $imgBeg = strpos($content, '<img', $start);
        $post = substr($content, $imgBeg);
        $imgEnd = strpos($post, '>');
        $postOutput = substr($post, 0, $imgEnd+1);
        $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
        if(stristr($postOutput,'<img')) { echo '<a href="'.$link.'">'.$postOutput."</a>"; }
        $start=$imgEnd+1;
    }
    $more = 0;
}

There's much more cleanup that may be done about this code too, however i just modified that which you had.