Get Youtube Video Id From Iframe Video
This field contains the ifrmae,something like this
Solution 2:
With javascript and regular expressions you can do like this:
var url = document.getElementById('myIframe').src,
regExp = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/,
videoId = url.match(regExp);
if (videoId && videoId[1].length === 11) {
console.log(videoId[1]);
}
<iframeid="myIframe"width="560"height="315"src="https://www.youtube.com/embed/ISMzgunUono"frameborder="0"allowfullscreen></iframe>
Solution 3:
You can try this:
<?php$string = $videoFirstArray['fileToUpload'];
$pattern = '!youtube.com/embed/([^"]+)!i';
preg_match($pattern, $string, $match);
print_r($match);
?>
The expected output should be something like this :
Array
(
[0] => youtube.com/embed/ISMzgunUono
[1] => ISMzgunUono
)
Btw this was taken by how to get Video id from iframe of youtube in php or cakephp
Post a Comment for "Get Youtube Video Id From Iframe Video"