Created
December 27, 2021 19:50
-
-
Save stefanpejcic/14eae87cdf2276f896b40f626ba7abc5 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( 'pcre.backtrack_limit', '50000000000' ); | |
ini_set( 'pcre.recursion_limit', '50000000000' ); | |
$inputfile = fopen( 'inputfile.sql', 'r' ); // replace this before running | |
$outputfile = fopen( 'outputfile.sql', 'w' ); // replace this before running | |
$regex = '/myregex/s'; | |
$lines = 0; | |
if ( $inputfile ) { | |
while ( ( $buffer = fgets( $inputfile ) ) !== false ) { | |
$lines ++; | |
echo 'Line:' . $lines . PHP_EOL; | |
$c = preg_replace( $regex, '', $buffer, -1, $count ); | |
fwrite( $outputfile, $c ); | |
} | |
if ( ! feof( $inputfile ) ) { | |
echo "Error: unexpected fgets() fail\n"; | |
} | |
fclose( $inputfile ); | |
fclose( $outputfile ); | |
echo "Done!\n"; | |
} else { | |
echo "Input issue!\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment