gpt4 book ai didi

php - 我怎样才能从中获取 URL?

转载 作者:可可西里 更新时间:2023-11-01 00:29:21 24 4
gpt4 key购买 nike

我收到了很多针对我网站的 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

但是有很多,我只想返回每个部分的 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

编辑:我将这些文件存储到一个 txt 文件中,然后使用标准代码调用它们。

$urls = file_get_contents( "oururls.txt" );
$data = explode(",", $urls);
foreach ($data as $item) {
echo "$item";
echo '<br>';
}

没什么特别的,它怎么也返回标题,我只想要url

最佳答案

如果 URL 后始终有一个空格,您可以用“”展开文本并获取第一部分。示例:

$example = explode(" ", $url);
echo $example[0];

关于php - 我怎样才能从中获取 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44087297/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com