pepebe
4/10/2014 - 9:42 AM

Grab youtube id from any anything possibly inserted into youtube text tv

Grab youtube id from any anything possibly inserted into youtube text tv

<?php
preg_match('#(\.be/|/embed/|/v/|/watch\?v=)([A-Za-z0-9_-]{5,11})#', $iframe, $matches);
    if(isset($matches[2]) && $matches[2] != ''){
         $youtubeID = $matches[2];
    }

$modx->setPlaceholder($ph,$youtubeID);

return;