How can I only get the url from this?

I am getting a lot of emails to remove DMCA for my site and I am trying to automate the process of removing these tracks from my site.

All emails look like this.

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

      

But there are a lot of them, I only want to return the url of each part of this, like below.

http://example.com/title-to-post.html
http://example.com/title-of-post.html
http://example.com/some-song-artist-some-song-name.html

      

EDIT: I store these files in a txt file and then call them using standard code.

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

      

Nothing really interesting how it would return the title and I only want the url .

+3


source to share


1 answer


If there is always a space after the url, you can explode the text with "" and get the first part. Example:



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

      

+6


source







All Articles