Letters
Moderator: General Moderators
-
Silver_Eclipse
- Forum Commoner
- Posts: 61
- Joined: Sun Aug 18, 2002 7:26 pm
Code: Select all
<?php
$if_name = "file.ext"; // inputfile_name
$of_name = "char.txt"; // outputfile_name
if (file_exists($if_name))
{
$f_contents = file($if_name);
$fd_out = fopen($of_name, "a+"); // only appending !?
$ln_gt = 62; // linenumber_greaterthan
$ln_lt = 4320; // linenumber_lesserthan
// include 'style.css'; <- uncertain about this
// include 'header.php'; <- and that
for ($ln = $ln_gt+1; $ln < count($f_contents) && $ln < $ln_lt; $ln++)
{
fputs($fd_out, $f_contentsї$ln]);
// you still can print it out now directly
// print($f_contentsї$ln]);
}
fputs($fd_out, "</table>");
fclose($fd_out);
/* if you want to read it back now - but just as reminder:
the data is already available ;)
*/
$f_contents = file($of_name);
}
else
printf('file not found: '.$if_name);
?>take a look at the for manual page
-
Silver_Eclipse
- Forum Commoner
- Posts: 61
- Joined: Sun Aug 18, 2002 7:26 pm
-
Silver_Eclipse
- Forum Commoner
- Posts: 61
- Joined: Sun Aug 18, 2002 7:26 pm
-
Silver_Eclipse
- Forum Commoner
- Posts: 61
- Joined: Sun Aug 18, 2002 7:26 pm
file() reads the file and returns the contents line by line in an array.
But -doh- I'm an idiot. Your while-loop is correct, since
while(list($array) = each($file))
will make $array contain the index of the current array-element in each iteration
Right after I will have pressed "submit" I'll shutdown my computer and burry my head under a pillow (that will soften the hits I'll give myself)
But -doh- I'm an idiot. Your while-loop is correct, since
while(list($array) = each($file))
will make $array contain the index of the current array-element in each iteration
Right after I will have pressed "submit" I'll shutdown my computer and burry my head under a pillow (that will soften the hits I'll give myself)