Page 3 of 3

Posted: Mon Aug 19, 2002 11:12 pm
by Silver_Eclipse
where did $ln come from? i understand that script u sent me now except for the $ln i know $ln_gt and $ln_lt are specified but where did just $ln come from?

Posted: Mon Aug 19, 2002 11:18 pm
by volka

Code: Select all

<?php 
$if_name = "file.ext"; // inputfile_name
$of_name = "char.txt"; // outputfile_name

if (file_exists($if_name)) 
&#123; 
   $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++) 
   &#123;
      fputs($fd_out, $f_contents&#1111;$ln]); 
      // you still can print it out now directly 
      // print($f_contents&#1111;$ln]);
   &#125;
   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);
&#125; 
else 
   printf('file not found: '.$if_name); 
?>
p.s.: $ln is defined and set before the loop-body of "for" is executed the first time ($ln = $ln_gt+1)

take a look at the for manual page

Posted: Mon Aug 19, 2002 11:33 pm
by Silver_Eclipse
thnx

Posted: Mon Aug 19, 2002 11:37 pm
by volka
poooh....finished.
As mentioned somewhere else here:
This is either my
"I will never be a teacher" day,
"I'm not a teacher" week or
"can't express anything" month

sorry 8O

Posted: Mon Aug 19, 2002 11:43 pm
by Silver_Eclipse
lol np i understand most of it

Posted: Mon Aug 19, 2002 11:45 pm
by Silver_Eclipse
$f_contents = file($of_name); looks like you are setting it to something and not reading it back?
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);
}

Posted: Mon Aug 19, 2002 11:52 pm
by Silver_Eclipse
oh yeah and the input files go with the read back part because one is a css style sheet for colors and stuff and the other is a graphic at the top of the page.

Posted: Mon Aug 19, 2002 11:56 pm
by volka
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)