- var_dump: documentation ( source)
- preg_replace_callback: documentation ( source)
<?php
function media_add($a) {
global $media_list;
$media_list[] = $a[0];
return $a[0];
}
$_content = '<p class="post_content">[iframe width="256" height="175" src="http://www.youtube.com/embed/ICx3AfSlc-w" frameborder="0" allowfullscreen]</p>
//www.youtu.be/asdlfkjad_1
https://www.youtube.com/watch?v=dZpc936_Hgo
http://youtu.be/lvOFck4dn_8
http://vimeo.com/65484727
http://www.metacafe.com/watch/10599819/are_katy_perry_and_john_mayer_back_together
http://www.dailymotion.com/video/xzdijh_hire-data-entry-expert_news
<embed style="width:400px; height:326px;" wmode="opaque" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=123456&hl=en" flashvars=""> </embed>
<embed src="http://blip.tv/play/gaUIx5A7AA" type="application/x-shockwave-flash" width="320" height="270" allowscriptaccess="always" allowfullscreen="true"></embed>
<div class="post_source_linkbar">
<img class="post_source_logo" src="http://economyincrisis.org/wp-content/uploads/2011/08/EICtext5.png"><img class="post_source_icon" title="Economy In Crisis" src="http://www.google.com/s2/favicons?domain=http%3A%2F%2Feconomyincrisis.org%2F">Source</div>';
preg_replace_callback(array(
'/(https?:|)\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com(?:\/embed\/|\/v\/|\/watch\?v=|\/ytscreeningroom\?v=|\/feeds\/api\/videos\/|\/user\S*[^\w\-\s]|\S*[^\w\-\s]))([\w\-]{11})[?=&+%\w-]*/i',
'/(https?:|)\/\/vimeo\.com\/(\d+)/i',
'/(https?:|)\/\/www\.metacafe\.com\/watch\/(\d+)\/(\w+)/i',
'/(https?:|)\/\/www\.dailymotion\.com[^\/]*\/video\/(\w+)/i',
'/(https?:|)\/\/video.google.[A-Za-z\.]{2,5}\/[^\?]+\?docid\=[0-9\-]+/i',
'/(https?:|)\/\/blip.tv\/play\/(\w+)/i'
), 'media_add', $_content);
/*
http://all4wp.blogspot.com/2008/03/regex-for-embed-video.html
https://www.youtube.com/watch?v=dZpc936_Hgo
http://youtu.be/lvOFck4dn_8
http://vimeo.com/65484727
http://www.metacafe.com/watch/10599819/are_katy_perry_and_john_mayer_back_together
http://www.dailymotion.com/video/xzdijh_hire-data-entry-expert_news
*/
var_dump($media_list);