我想从混合字符串中获取所有网址。 我的字符串:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000000.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000001.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000002.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000003.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000004.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
http://media.com/S1/HLS_VOD/26c2_1561/2500/segm000005.ts?key=49bfee85b05d117a2906368428094e94
#EXTINF:10,
我的php代码:
function getUrls($string) {
$regex = '/https?\:\/\/[^\" ]+/';
preg_match_all($regex, $string, $matches);
//return (array_reverse($matches[0]));
return ($matches[0]);
}
$urls = getUrls($videourlget);
print_r($urls);
但它不会返回网址。我想只返回字符串中的URL-s。有什么想法吗?