Find Nth Image in HTML

[norebro_social_networks icon_layout=”boxed”]

Using below function you can find Nth Image in your HTML Code

function getImageInHTML($post, $default, $i = 0)
{
    preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post, $matches);
    if( isset($matches[1][$i]) && !empty( $matches[1][$i] )){return $matches[1][$i];}
    if(isset($matches[1][0]) && !empty( $matches[1][0] )){return $matches[1][0];}
    return $default;
}
https://www.kodeinfo.com
Comments to: Find Nth Image in HTML

    Your email address will not be published. Required fields are marked *

    Attach images - Only PNG, JPG, JPEG and GIF are supported.

    Stay connected

    Categories

    Newsletter

    Tags

    Recent Comments

      Recent Posts

      Recent Comments

        Archives

        Categories

        Meta