Re: How to display one line from a file rather than the whole lot
| From: | Julio Nobrega Trabalhando | Date: | Fri, 30 Nov 2001 13:48:37 +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-76199@lists.php.net to get a copy of this message | ||
Dirty trick:
<?php
$line_I_want = '47';
// 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";
if ($line_I_want == $line_num) {
$dirty_trick = htmlspecialchars($line);
}
}
echo $dirty_trick;
?>
No knowledge of what number is the line:
<?php
// get a web page into an array and print it out
$filename = 'http://www.php.net;
$fd = fopen ($filename, 'r');
$read = fread($fd, 30000);
fclose($fd);
$search = eregi('what_comes_before_the_line_you_want(.*)what_comes_after',
$read, $printing);
echo $printing[1];
?>
--
Julio Nobrega
No matter where you go, &this.
"Kevin Garrett" <kevgar90@hotmail.com> wrote in message
news:F133zgXommqwfssnG2L0000cddb@hotmail.com...
> 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
>