php - Get only one line from a web page -


hi, have file test1.php , in other file test.php have php code running:

<?php $file = "http://inviatapenet.gethost.ro/sop/test1.php"; $line = '0'; if($f = fopen($file, 'r')){   $line = fgets($f); // read until first newline   fclose($f); } echo $line; ?> 

the idea second line of web page test1.php.

second line

i've tried change $line = '2'; no affect, displays first line. need help.

this should work. obviously, change value of $linetofetch:

<?php // write here number of line want fetch. $linetofetch = 2;  $file = "http://inviatapenet.gethost.ro/sop/test1.php"; $currentline = 1; if($f = fopen($file, 'r')){   while ($currentline <= $linetofetch) {     $line = fgets($f); // read until first newline     $currentline++;     }   fclose($f);   } echo $line; ?> 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -