Skip to content

Instantly share code, notes, and snippets.

@pyaesone17
Created December 22, 2017 15:24
Show Gist options
  • Save pyaesone17/a16582b4396dc69c27a9c0e7003d5ad7 to your computer and use it in GitHub Desktop.
Save pyaesone17/a16582b4396dc69c27a9c0e7003d5ad7 to your computer and use it in GitHub Desktop.
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