Created
October 23, 2012 17:37
-
-
Save ahawthorne/3940260 to your computer and use it in GitHub Desktop.
search and replace, recalculate string-length in serialized array
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 | |
| $in = file_get_contents('input.sql'); | |
| // change domain(s) | |
| $in = preg_replace('/old.example.com/', 'new.example.com', $in); | |
| $in = preg_replace('/older.example.com/', 'newer.example.com', $in); | |
| // recalculate string lengths in serialized arrays | |
| $out = preg_replace('/s:(\d+):\\\"(.*?)\\\";/e', "'s:'.strlen('$2').':\"$2\";'", $in); | |
| file_put_contents('output.sql', $out); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment