可以使用 explode 函数和 str_replace 函数来获取需要的字符串:/n/nphp/n$url='https://cdn.sdh9.cn/20211029/lL2jLXPu/2000kb/hls/index.m3u8';/n$parts = explode('/', $url);/n$file = str_replace($parts[0].'/'.$parts[1].'/', '', $url);/necho $file; // 输出:20211029/lL2jLXPu/2000kb/hls/index.m3u8/n/n/n首先使用 explode 函数将 /$url 按照 '/' 分割成数组 /$parts,然后使用 str_replace 函数将 /$url 中的前两个部分替换为空字符串,即去掉 'https://cdn.sdh9.cn/' 和 '20211029/',得到需要的字符串。最后输出结果即可。

PHP 获取 URL 中的特定路径字符串

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

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