#1 (permalink)  
Old 09-25-04, 01:31 PM
gevorgkhc gevorgkhc is offline
Newbie Coder
 
Join Date: Feb 2004
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Help!

is there a short way to just read the first line of a file? cuz fread() needs a specific length and the file changes all the time and so I'm lost. Please help!
Reply With Quote
  #2 (permalink)  
Old 09-25-04, 02:06 PM
<?Wille?> <?Wille?> is offline
Junior Code Guru
 
Join Date: Jan 2004
Location: Helsinki, Finland
Posts: 666
Thanks: 0
Thanked 0 Times in 0 Posts
you might want to try file().. but i wont guarantee any success with it
Reply With Quote
  #3 (permalink)  
Old 09-25-04, 03:15 PM
Eclipse's Avatar
Eclipse Eclipse is offline
Coding Addict
 
Join Date: May 2004
Location: Long Island, New York
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
no I think that you should try something like: fread($open,filesize($file)); Hope that helps....
Reply With Quote
  #4 (permalink)  
Old 09-25-04, 08:20 PM
mikaelf mikaelf is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: php[dot]net
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
hi gevorgkhc,
simply use php function fgets:
Code:
string fgets ( resource handle [, int length])
Usage:
PHP Code:

$fp fopen('/path/to/yourfile.ext','r');

$firstline fgets($fp,4096);
print 
$firstline;

//To reread firstline
rewind($fp);
$firstline2=fgets($fp,4096);
print 
$firstline
__________________
Useful PHP links:
bugs.php.net - for reporting PHP bugs
pear.php.net - PHP extension and application repository
pecl.php.net - get non standard PHP modules, submit yours
www.phpclasses.org - PHP classes repository
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 04:33 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.