Add more options in preg_match_all

0

I have this little code in preg_match_all , which follows a pattern that copies three urls that start with, /lima.php?s=img&v= ,/lima.php?s=ik&v= , /lima.php?s=zk&v= and copies the image paths of each one starts here after &v=:

The complete url would be like that of the 3:

/lima.php?s=img&v=rutadelaprimeraimagenquecopia
/lima.php?s=ik&v=rutadelaprimeraimagenquecopia
/lima.php?s=zk&v=rutadelaprimeraimagenquecopia 

But there's another option that starts with:

/tarapoto.php?top=rutaimgenquesecopia

It's that last option that I can not get you to copy and I'd like to know how you could join both lima.php and tarapoto.php in this piece of code:

function getimagenhash($link){  
    preg_match('/lima\.php\?s\=((img|ik|zk)\&v\=((([\w-\=]+))))/',$link, $matches, PREG_OFFSET_CAPTURE);
    if(count($matches)>1);{
        if(isset( $matches[3])){
            return $matches[3][0];
        }
    }
    return false;
}

If someone helps me please: /

    
asked by Kiara 06.12.2018 в 18:23
source

0 answers