In simple PHP,I am use this code :
Url :have code that same as you genrate that appended at the end of url.I am work with core php.
$url="http://www.youtube.com/watch?v=fHBFvlQ3JGY";
preg_match(
'/[\\?\\&]v=([^\\?\\&]+)/',
$url,
$matches
);
$id = $matches[1];
$width="640";
$height="385";
echo '<object width="' . $width . '" height="' . $height . '"><param name="movie" value="http://www.youtube.com/v/' . $id . '&hl=en_US&fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' . $id . '&hl=en_US&fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="' . $width . '" height="' . $height . '"></embed></object>';