我都試過,但它的失敗:YouTube鏈接不給視頻ID
$whereIsMyCake = '';
//
// put all the links here
//
$url = "http://www.youtube.com/embed/more_yougooglelink";
$url = "http://www.youtube.com/v/..." // works
$url = "http://www.youtube.com/watch?v=ue1mLnyEd90"; // WORKS
$url = "http://youtu.be/we_youGoogle_u"; // WORKS
parse_str(parse_url($url, PHP_URL_QUERY), $my_array_of_vars);
if($my_array_of_vars['v']=='') {
preg_match(
"#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+(?=\?)|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#",
$url,
$matches);
$whereIsMyCake = $matches[0];
} else {
$whereIsMyCake = $my_array_of_vars['v'];
}
echo $whereIsMyCake;
問:現在看來youtube.com/embed/videoid is here
不工作,如果YouTube對,我們必須不斷地改變我們的算法,新的聯繫是什麼? for youtube.com/embed/embed.weareruling/embed/embed/googleisboss/findmenow/video id is here ?
「Gimme teh codes」...你到目前爲止試過了什麼?因爲簡單的'strstr'和'substr'應該給你正確的結果很快,問題是什麼? – Vyktor