note 88549 added to function.readfile

From: Date: Wed, 28 Jan 2009 20:25:22 +0000
Subject: note 88549 added to function.readfile
Groups: php.notes 
Request: Send a blank email to php-notes+get-149906@lists.php.net to get a copy of this message
Here is my version of readfile_chunked you can make it act like file() or file_get_contents() by using the type arg function readfile_chunked ($filename,$type='array') { $chunk_array=array(); $chunksize = 1*(1024*1024); // how many bytes per chunk $buffer = ''; $handle = fopen($filename, 'rb'); if ($handle === false) { return false; } while (!feof($handle)) { switch($type) { case'array': // Returns Lines Array like file() $lines[] = fgets($handle, $chunksize); break; case'string': // Returns Lines String like file_get_contents() $lines = fread($handle, $chunksize); break; } fclose($handle); return $lines; } enjoy! ---- Server IP: 209.41.74.194 Probable Submitter: 71.125.8.10 ---- Manual Page -- http://www.php.net/manual/en/function.readfile.php Edit -- https://master.php.net/note/edit/88549 Del: integrated -- https://master.php.net/note/delete/88549/integrated Del: useless -- https://master.php.net/note/delete/88549/useless Del: bad code -- https://master.php.net/note/delete/88549/bad+code Del: spam -- https://master.php.net/note/delete/88549/spam Del: non-english -- https://master.php.net/note/delete/88549/non-english Del: in docs -- https://master.php.net/note/delete/88549/in+docs Del: other reasons-- https://master.php.net/note/delete/88549 Reject -- https://master.php.net/note/reject/88549 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#149906) next »