i have implemented a function for grabbing Youtube ID and i use the regular expression:
preg_match('%(?:youtube(?:-nocookie)?\.com/(?:(?:v|e(?:mbed)?)/|.*[?&]v=|[^/]+/.+/)|youtu\.be/)([^"&?/ ]{11})%i', $sourceCode, $youtube))
My problem is that this resular expression doesn't collect the id from a URL like: http://img.youtube.com/vi/Di9mQ35zprs/0.jpg
So, how can i change it to work as it works right now but by giving me the "Di9mQ35zprs" from a URL "http://img.youtube.com/vi/Di9mQ35zprs/0.jpg" too?
- THERE ARE MANY OTHER QUESTIONS REGARDING GRABBING YOUTUBE ID WITH PREG_MATCH, BUT NOONE OF THEM ANSWERS HOW TO GRAB FROM A URL http://img.youtube.com/vi/Di9mQ35zprs/0.jpg TOO.
Thank you!