RE: [PHP] Lines

From: Date: Wed, 25 Apr 2001 17:13:40 +0000
Subject: RE: [PHP] Lines
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50323@lists.php.net to get a copy of this message
I should tell you that the "text file" is an htm that i have to print withou the header "<HTML><TITLE>...." and footer "</BODY></HTML>" :PP Rafael
I know, it was already answered before me (you), I just though that an SQL database is a good advice for these who are trying to do this kind of jobs. It is obvious that the reason to use this function is to manage a stored data in files. then why not a database, if possible? Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Jason Murray [mailto:Jason.Murray@melbourneit.com.au] Sent: Wednesday, April 25, 2001 4:52 PM To: Maxim Maletsky; 'Rafael Faria'; php-general@lists.php.net Subject: RE: [PHP] Lines
it's my first post on this list, and my doubt is... how can i take a file.txt and 1 - know how many lines i have in this text 2 - print line 5 until 10
Is there any chance for you to use a database? these thing would become MUCH, MUCH easier. Actually, this is really easy without using a database. 1. <?
      $filename = "/path/to/file";
      $filedata = file($filename);
      $linesinfile = count($filedata);
?> 2. <?
      $startline = 5;
      $stopline = 10;
      for ($i = $startline; $i < $stopline; $i++ )
      {
        echo $filedata[$i-1];
      }
?> (Use $i-1 because the first line is actually "0"). Jason
--- [ r a f a e l f a r i a] _____________________ _________________rafaelrfc@uol.com.br WebMaster Universo Online - http://www.uol.com.br Phone # +55 11 3038-8665

« previous php.general (#50323) next »