可以使用explode函数和str_replace函数来获取需要的字符串:

$url='https://cdn.sdh9.cn/20211029/lL2jLXPu/2000kb/hls/index.m3u8';
$parts = explode('/', $url);
$file = str_replace($parts[0].'/'.$parts[1].'/', '', $url);
echo $file; // 输出:20211029/lL2jLXPu/2000kb/hls/index.m3u8

首先使用explode函数将$url按照"/"分割成数组$parts,然后使用str_replace函数将$url中的前两个部分替换为空字符串,即去掉"https://cdn.sdh9.cn/"和"20211029/",得到需要的字符串。最后输出结果即可。

$url=httpscdnsdh9cn20211029lL2jLXPu2000kbhlsindexm3u8;使用php得到20211029lL2jLXPu2000kbhlsindexm3u8

原文地址: https://www.cveoy.top/t/topic/hcRu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录