Re: How to display one line from a file rather than the whole lot

From: Date: Fri, 30 Nov 2001 12:24:41 +0000
Subject: Re: How to display one line from a file rather than the whole lot
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-76198@lists.php.net to get a copy of this message
The key will be to put some kind of 'if' around your echo statement, but since you didn't say what the criteria for display is it's pretty tough to help any further. If the criteria is content driven, preg_match or ereg are you're answer, if it's the X'th line in the file then you could probably just index the $fcontents array directly and echo $fcontents[$linenumberIwant]; Hank On Fri, Nov 30, 2001 at 12:51:19PM +0000, Kevin Garrett wrote: > Hi guys, > > I'm looking to edit this to just return one particular line rather than the > whole file: > > <?php > // get a web page into an array and print it out > $fcontents = file ('http://www.php.net'); > while (list ($line_num, $line) = each ($fcontents)) { > echo "<b>Line $line_num:</b> " . htmlspecialchars ($line) . > "<br>\n"; > } > ?> > > Can anybody help me? > Kev > > _________________________________________________________________ > Get your FREE download of MSN Explorer at > http://explorer.msn.com/intl.asp > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > -- Hank Marquardt <hank@yerpso.net> http://web.yerpso.net GPG Id: 2BB5E60C Fingerprint: D807 61BC FD18 370A AC1D 3EDF 2BF9 8A2D 2BB5 E60C *** Web Development: PHP, MySQL/PgSQL - Network Admin: Debian/FreeBSD *** PHP Instructor - Intnl. Webmasters Assn./HTML Writers Guild *** Beginning PHP -- Starts January 7, 2002 *** See http://www.hwg.org/services/classes

« previous php.general (#76198) next »