View Full Version : deleting the first line of a text file with php

12-04-2005, 01:38 AM
how is it done?

12-04-2005, 03:19 PM
just type in the text file like this:
(im assuming you know that // means comment)

$array = file('text.txt'); // Takes the file, and puts it in an array each seperated
// by line.
$array[0] = ""; // Deleted the first line, $array[1] is second line... etc.
foreach($array as $val){ // Put the array into a loop, and displayed every line.
echo $val."<br />"; // Echo the line, then line break
} // close our loop

This only replaces the first line with a blank text, however it is not permanent, if you want to actually remove it and SAVE the file with the first line deleted, then you need to fwrite() or fputs() it.

12-04-2005, 05:28 PM
that's great, cheers!