Remove first or last line from txt file in php
<== remove.php start ==>
// load the data and delete the line from the array
$lines = file('file.txt');
$last = fgets($f); // use for first line removing
$last = sizeof($lines) - 1 ; // use for last line removing
unset($lines[$last]);
// write the new data to the file
file_put_contents('file.txt', $lines);
<== file.txt start ==>
facebook.com
fonts.googleapis.com
google.com
youtube.com
twitter.com
instagram.com
googletagmanager.com
linkedin.com
fonts.gstatic.com
gmpg.org
ajax.googleapis.com
maps.google.com
youtu.be
support.google.com
wordpress.org
cdnjs.cloudflare.com
play.google.com
plus.google.com
en.wikipedia.org
pinterest.com
docs.google.com
drive.google.com
s.w.org
bit.ly
github.com
goo.gl
secure.gravatar.com
amazon.com
itunes.apple.com
vimeo.com
developers.google.com
policies.google.com
vk.com
accounts.google.com
t.co
medium.com
flickr.com
creativecommons.org
w3.org
reddit.com
code.jquery.com
ec.europa.eu
gstatic.com
google-analytics.com
soundcloud.com
player.vimeo.com
support.apple.com
open.spotify.com
apps.apple.com
microsoft.com
storage.googleapis.com
lh3.googleusercontent.com
sites.google.com
tiktok.com
t.me
forbes.com
slideshare.net
cloudflare.com
nytimes.com
cdn.jsdelivr.net
paypal.com
i0.wp.com
maps.googleapis.com
mail.google.com
tinyurl.com
apple.com
calendar.google.com
theguardian.com
apis.google.com
adobe.com
archive.org
chrome.google.com
meetup.com
forms.gle
etsy.com
support.microsoft.com
<== file.txt end ==>