我需要在变量http://www.example.com/video-play.mp4?contentId=XXXXXXXX
存储ID之后获取任何ID以供以后使用
在每个帖子中都有不同的视频ID
$video_string = '[videojs mp4="http://www.example.com/video-play.mp4?contentId=7c6255ca14e901d2" poster="https://2.bp.example.com/-lSTjYuDBiAQ/VvST8Z7z2OI/AAAAAAAAGPY/c8yAE675bLEMYI-OMwtauCiXeu1yZPZaw/s1600/fundososvideos.jpg" preload="none" controls="controls" width="100%" height="400"]';
if (preg_match('/mp4="(.*)"\sposter/', $video_string, $matches1)) {
$url = $matches1[1];
$id = explode('=',parse_url($url)['query'])[1];
echo 'From Video string I get Id= '.$id . ' & url = '.$url;
}
答案 0 :(得分:0)
我认为您正在寻找parse_url
功能。
查找文档here
答案 1 :(得分:0)
试试这个
$video_string = '[videojs mp4="http://www.blogger.com/video-play.mp4?contentId=7c6255ca14e901d2" poster="https://2.bp.blogspot.com/-lSTjYuDBiAQ/VvST8Z7z2OI/AAAAAAAAGPY/c8yAE675bLEMYI-OMwtauCiXeu1yZPZaw/s1600/fundososvideos.jpg" preload="none" controls="controls" width="100%" height="400"]';
if (preg_match('/mp4="(.*)"\sposter/', $video_string, $matches1)) {
$url = $matches1[1];
$query_args = parse_url($url, PHP_URL_QUERY);
$id = explode('contentId=', $query_args)[1];
echo 'From Video string I get Id= '.$id . ' & url = '.$url;
}