php - Any preg_match to check if a url is a youtube/vimeo/dailymotion video link? -
URL / YouTube / Video / Dailymotion video link, what is the best preg_match syntax to know?
If this is difficult, then just check the domain name.
Thank you
I preg_match ()
I do not use it, I think maybe a better option, you can pass a URL string in it, and it will break it for you in all subcomputations.
I do not know what you think of specific video URLs for those sites, I'm sure you can come up with some identification criteria for each identifier, which you can call parse_url ()
with the results. For example, here's what the breakdown of YouTube link can look like:
$ res = parse_url ("http://www.youtube.com/watch?v=Sv5iEK -IEzw "); Print_r ($ race); / * Output: Array ([scheme] = & gt; http [host] => www.youtube.com [path] => [clock] => v = S55iEK-IEzw) * /
You can probably identify it on the host name and the path in this case.
Comments
Post a Comment