Skip to content

Instantly share code, notes, and snippets.

@pepebe
Created April 10, 2014 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepebe/10362312 to your computer and use it in GitHub Desktop.
Save pepebe/10362312 to your computer and use it in GitHub Desktop.
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment