我为我的网站收到了很多DMCA删除电子邮件,我正在尝试自动从我的网站删除这些曲目的过程.
所有的电子邮件看起来都与此类似.
http://example.com/title-to-post.html title - to post
http://example.com/title-of-post.html title - of post
http://example.com/some-song-artist-some-song-name.html some song artist - some song name
Run Code Online (Sandbox Code Playgroud)
但是它们中有很多,我只想返回其中每个部分的URL部分,例如下面的例子.
http://example.com/title-to-post.html
http://example.com/title-of-post.html
http://example.com/some-song-artist-some-song-name.html
Run Code Online (Sandbox Code Playgroud)
编辑:我将这些文件存储到txt文件,然后使用标准代码调用它们.
$urls = file_get_contents( "oururls.txt" );
$data = explode(",", $urls);
foreach ($data as $item) {
echo "$item";
echo '<br>';
}
Run Code Online (Sandbox Code Playgroud)
没有什么真正的花哨,它如何回归标题,我只想要网址.
如果URL后面总是有空格,你可以用""分解文本并得到第一部分.例:
$example = explode(" ", $url);
echo $example[0];
Run Code Online (Sandbox Code Playgroud)