Created
November 6, 2018 17:53
-
-
Save kadko/8b9466d98ba2ec77fcbd83a4bb725db5 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
ini_set('memory_limit', '-1'); | |
ini_set('max_execution_time', 30000); | |
$sampleSQL = file_get_contents('sampleSQL.txt'); | |
$past = 0; | |
$PIN = ');'; | |
$PINlen = mb_strlen( $PIN ); | |
$partSize = 0.2*1024*1024;//BYTES, 20MB | |
$len = mb_strlen($sampleSQL) / $partSize; | |
echo 'Total File: ' . floor($len); | |
echo '<br>'; | |
echo 'Each File Size: ' . $partSize; | |
echo '<br>'; | |
echo 'Each File Size(MB): ' . $partSize/(1024*1024); | |
for($i=1; $i < $len; $i++){ | |
$splitpos = mb_strpos($sampleSQL, $PIN, $i * $partSize); | |
if( $i == floor($len) ){ | |
$part = mb_substr($sampleSQL, $past + $PINlen ); | |
}else{ | |
if($i != 1){ $marginS = $PINlen; $marginE = 0; }else{ $marginS = 0; $marginE = $PINlen; } | |
$part = mb_substr($sampleSQL, $past + $marginS, $splitpos-$past + $marginE ); | |
} | |
$past = $splitpos;//get previous last as current start offset | |
file_put_contents($i, $part); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment