note 49992 added to function.fseek

From: Date: Mon, 14 Feb 2005 22:25:25 +0000
Subject: note 49992 added to function.fseek
Groups: php.notes 
Request: Send a blank email to php-notes+get-85033@lists.php.net to get a copy of this message
Based on the function below, provided by info at o08 dot com (thanks), the following should enable you to read a single line from a file, identified by the line number (starting with 1): <? function readLine ($linenum,$fh) { $line = fgets ($fh, 4096); $pos = -1; $i = 0; while (!feof($fh) && $i<($linenum-1)) { $char = fgetc($fh); if ($char != "\n" && $char != "\r") { fseek($fh, $pos, SEEK_SET); $pos ++; } else $i ++; } $line = fgets($fh); return $line; } //readLine() ?> ---- Manual Page -- http://www.php.net/manual/en/function.fseek.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49992 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49992&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49992&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49992&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49992&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49992&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49992&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#85033) next »