<?php

function parse_yturl($url)
{
    $pattern = '#^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch\\?v=|/watch\\?.+&v=))([\\w-]{11})(?:.+)?$#x';
    preg_match($pattern, $url, $matches);
    return isset($matches[1]) ? $matches[1] : false;
}
echo parse_yturl($_REQUEST['videoid']);
      <!-- Video Modal -->      
      <div id="entryModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
          <h3 id="myModalLabel"><?php 
echo $project_title;
?>
</h3>
        </div>
        <div class="modal-body">
          
           <?php 
$dispVideo = str_replace('//vimeo.com', '//player.vimeo.com/video', $project_video);
//youtube has two type of url formats we need to look for and change
$videoID = parse_yturl($dispVideo);
if ($videoID != '') {
    $dispVideo = 'https://www.youtube.com/embed/' . $videoID;
}
?>
            
            <input id="entryVideo" type="hidden" value="<?php 
echo $dispVideo;
?>
" />
            <iframe width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>

        </div>
      </div>
      
<!-- Commenting out for now via Clair
Example #3
0
<?php

/*
**********************************

	PHPOS Web Operating system
	MIT License
	(c) 2013 Marcin Szczyglinski
	szczyglis83@gmail.com
	GitHUB: https://github.com/phpos/
	File version: 1.0.0, 2013.10.08
 
**********************************
*/
if (!defined('PHPOS')) {
    die;
}
function parse_yturl($url)
{
    $pattern = '#^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch\\?v=|/watch\\?.+&v=))([\\w-]{11})(?:.+)?$#x';
    preg_match($pattern, $url, $matches);
    return isset($matches[1]) ? $matches[1] : false;
}
$u = parse_yturl($url);
$jquery = "\n\t\t\n\t\tvar media_width = 600;\n\t\tvar media_height = 400;\n\t\t\n\t\tvar url = '" . $u . "';\n\t\tvar media_left = (\$(window).width()/2)-(media_width/2);\n    var media_top = (\$(window).height()/2)-(media_height/2);\n\t\t\n\t\tvar w = window.open('http://www.youtube.com/embed/" . $u . "?autoplay=1', 'PHPOS: yt'+Math.random(),'top='+media_top+',left='+media_left+',resizable=no, height='+media_height+',width='+media_width);\n\t\tw.focus();\n\t\t" . winclose(WIN_ID) . "\n\t\t";
$my_app->jquery_onready($jquery);