[PHP] How to display one line from a file rather than the whole lot

2001-11-30 Thread Kevin Garrett

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 bLine $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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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

2001-11-30 Thread Hank Marquardt

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 +, 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 bLine $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: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 

-- 
Hank Marquardt [EMAIL PROTECTED]
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]