hello iam new in php i want to reed first 5 lines in text file then i want to delete first 5 lines in a text file "1.txt" i tried multi codes before i want to make a iframe from first 5 lines in the text then delete them and update the file <?php $myFile = "1.txt"; $lines = file($myFile);//file in to an array { print "<iframe width=300 height=260 src=" . $line[1] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $line[2] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $line[3] . "></iframe><br />\n"; } $File = "1.txt"; $Handle = fopen($File, 'w'); delete($Handle, $lines[1]); delete($Handle, $lines[2]); delete($Handle, $lines[3]); fclose($Handle); ?> Code (markup):
loop through and any lines after #5 get added to a new string, then overwrite the old file with the new string.
<?php $myFile = "1.txt"; $lines = file($myFile);//file in to an array print "<iframe width=300 height=260 src=" . $lines[0] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $lines[1] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $lines[2] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $lines[3] . "></iframe><br />\n"; print "<iframe width=300 height=260 src=" . $lines[4] . "></iframe><br />\n"; $i = 0; $content = ""; do { $content .= $lines[$i] . "\n"; } while ($i > 4); $Handle = fopen($myFile, 'w'); fwrite($Handle, $content); fclose($Handle); ?> PHP: That should work for you.