Php 分解youtube代码表单字符串

Php 分解youtube代码表单字符串,php,youtube,Php,Youtube,大家好,我面临一个问题,无法从特定字符串中爆炸aMwLAI\u TXowca, 我想从以下youtube代码中爆炸MwLAI_TXowc <iframe width="640" height="360" src="https://www.youtube.com/embed/MwLAI_TXowc" frameborder="0" allowfullscreen=""></iframe> 请帮助我如何从youtube中分解MwLAI_TXowc,并在php中嵌入代码。

大家好,我面临一个问题,无法从特定字符串中爆炸aMwLAI\u TXowca, 我想从以下youtube代码中爆炸MwLAI_TXowc

<iframe width="640" height="360" src="https://www.youtube.com/embed/MwLAI_TXowc" frameborder="0" allowfullscreen=""></iframe>

请帮助我如何从youtube中分解MwLAI_TXowc,并在php中嵌入代码。
提前感谢

您不必使用PHP函数
explode
,因为这个PHP函数
pathinfo
要简单得多

<?php

$url = 'https://www.youtube.com/embed/MwLAI_TXowc';
$basename = pathinfo($url)['basename'];

echo '<pre>';
var_dump($basename);
echo '<pre>';

?>
或者如果您的PHP不支持使用函数直接访问数组

$s = '<iframe width="640" height="360" src="https://www.youtube.com/embed/MwLAI_TXowc" frameborder="0" allowfullscreen=""></iframe>';
preg_match('/.*"http.*\/embed\/(.*?)".*/', $s, $matches);

var_dump($matches);

为字符串使用preg_match

$s='';
preg_match('/.''http.*\/embed\/(.*)。*/',$s,$matches);
var_dump($matches);
<?php 

$url = 'https://www.youtube.com/embed/MwLAI_TXowc';
$pathinfo = pathinfo($url);
$basename = $pathinfo['basename'];

echo '<pre>';
var_dump($basename);
echo '<pre>';

?> 
string(11) "MwLAI_TXowc"
$s = '<iframe width="640" height="360" src="https://www.youtube.com/embed/MwLAI_TXowc" frameborder="0" allowfullscreen=""></iframe>';
preg_match('/.*"http.*\/embed\/(.*?)".*/', $s, $matches);

var_dump($matches);