我想从嵌入代码中获取 Youtube URL 的最后一部分,例如:
<iframe width="420" height="315" src="http://www.youtube.com/embed/gaDa2Zgtqo" frameborder="0" allowfullscreen></iframe>
我想要得到的部分是gaDa2Zgtqo
我尝试过使用爆炸,例如
$string = '<iframe width="420" height="315" src="http://www.youtube.com/embed/gaDa2Zgtqo" frameborder="0" allowfullscreen></iframe>'
$exploded = explode('/', $string);
echo $exploded[2]
但这只会导致结果www.youtube.com
。
我可以使用另一种方法吗?