1

i have this iframe

<iframe width="425" height="349" src="http://www.youtube.com/embed/YRUG-Pu7RzE" frameborder="0" allowfullscreen></iframe>

how to get video id from it by regular expression or any.....

chetanspeed511987
  • 1,995
  • 2
  • 22
  • 34

1 Answers1

0

You can use:

$subject = '<iframe width=\"425\" height=\"349\" src=\"http://www.youtube.com/embed/YRUG-Pu7RzE\" frameborder=\"0\" allowfullscreen></iframe>';
$pattern = '!http://(?:www.)?youtube.com/embed/([^"']+)!i';
$result = preg_match($pattern, $subject, $subpattern); 

$subpattern will contain:

Array ( [0] => http://www.youtube.com/embed/YRUG-Pu7RzE [1] => YRUG-Pu7RzE )
Leif
  • 2,143
  • 2
  • 15
  • 26