Created
February 4, 2019 14:20
-
-
Save Langmans/2f2e8b9776cc105282bb73c88819e152 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
<?php | |
$fh_read = fopen('alldb.sql', 'r'); | |
$fh_write = null; | |
$dbname = null; | |
while ($line = fgets($fh_read)) { | |
if (preg_match('@-- Current Database: `([^`]+)`@', $line, $m)) { | |
if ($fh_write) { | |
echo 'Closing ', $dbname, '<br>'; | |
fclose($fh_write); | |
} | |
$dbname = $m[1]; | |
$fh_write = fopen($m[1] . '.sql', 'w'); | |
echo 'Opening ', $dbname, '<br>'; | |
} | |
if ($fh_write) { | |
fwrite($fh_write, $line); | |
} | |
} | |
if ($fh_write) { | |
fclose($fh_write); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment