Say I have a list of IDs like so:
http://www.youtube.com/watch?v=KMU0tzLwhbE http://youtu.be/KMU0tzLwhbE http://www.youtube.com/watch?v=KMU0tzLwhbE&featured=
Try something like:
$pattern = '/(?:(?:\?|&)v=|\/)([A-Za-z0-9]{11})/'; $url = 'http://www.youtube.com/watch?v=KMU0tzLwhbE'; preg_match($pattern, $url, $matches); echo $matches[1];