Last active
May 10, 2017 07:13
-
-
Save ayebare/72fa52afd7a04fcaf4db1a7d9aa59ad3 to your computer and use it in GitHub Desktop.
Cleaning invalid characters in a list of xml files
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 | |
| $path_to_xmls = 'updated/problem-updated/*.{wxr,xml}'; | |
| $files = glob( $path_to_xmls, GLOB_BRACE ); | |
| foreach ( $files as $file ) { | |
| echo "{$file} \n"; | |
| $path_to_file = $file; | |
| $file_contents = file_get_contents( $path_to_file ); | |
| $file_contents = preg_replace( '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $file_contents ); | |
| file_put_contents( $path_to_file, $file_contents ); | |
| } | |
| echo 'done'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment