Welcome Guest, Not a member yet? Register   Sign In
Regular expression with YouTube videos [solved]
#3

[eluser]ejangi[/eluser]
I just very quickly threw this together and it seems to grab just the URL:
Code:
$string = '&lt;object width="425" height="355"&gt;<param name="movie" value="http://www.youtube.com/v/5PsnxDQvQpw&rel=1"></param><param name="wmode" value="transparent"></param>&lt;embed src="http://www.youtube.com/v/5PsnxDQvQpw&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;';
preg_match('/http:\/\/www\.youtube[^"]+/', $string, $matches);
$url = $matches[0];

You may want to check it on a few different movies though just to be sure.


Messages In This Thread
Regular expression with YouTube videos [solved] - by El Forum - 12-18-2007, 06:12 PM
Regular expression with YouTube videos [solved] - by El Forum - 12-18-2007, 08:13 PM
Regular expression with YouTube videos [solved] - by El Forum - 12-18-2007, 08:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB