Created
December 22, 2017 15:24
-
-
Save pyaesone17/a16582b4396dc69c27a9c0e7003d5ad7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function file_get_contents_chunked($file,$chunk_size,$callback) | |
{ | |
try | |
{ | |
$handle = fopen($file, "r"); | |
$i = 0; | |
while (!feof($handle)) | |
{ | |
call_user_func_array($callback,array(fread($handle,$chunk_size),&$handle,$i)); | |
$i++; | |
} | |
fclose($handle); | |
} | |
catch(Exception $e) | |
{ | |
trigger_error("file_get_contents_chunked::" . $e->getMessage(),E_USER_NOTICE); | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment