I have a PHP array like so (comes from a MySQL database, YouTube is just an example):
[regexpr] => array(4) (
[0] => (string) http://*.youtube.com/v/*
[1] => (string) https://*.youtube.com/v/*
[2] => (string) http://youtu.be/*
[3] => (string) http://m.youtube.com/watch*
)
Now, what I am trying to achieve is to find any of the matches in a URL (in this case: checking if the URL is a valid YouTube URL).
What I have tried is the following:
for($i = 0; $i < count($regexpr); $i++)
$regexpr[$i] = preg_quote($regexpr[$i]); // because of the URLs
$expr = '/(('. implode('|', $regexpr) . '))/i'; // Concatenating the ORs
$found = preg_match($expr, 'http://www.youtube.com/[foo]&v=MyVidID', $matches);
However, unfortunately, I was unable to successfully concatenate these expressions - I am not getting any successful "hits".
Would anyone have a pointer as to how to solve this issue?
¡Gracias!