Created
June 19, 2013 16:35
-
-
Save tomasfejfar/5815740 to your computer and use it in GitHub Desktop.
Compare two ini files with different formats. Will sort the keys and dump php arrays. Really useful for mysql/apache conf.
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 | |
| /** | |
| * INI configurations compare | |
| * | |
| * Usage: php compare.php file1.ini file2.ini | |
| * Result: Will export sorted arrays into *.res files to use with normal diff tool | |
| */ | |
| $x = parse_ini_file($argv[1],true); | |
| $y = parse_ini_file($argv[2],true); | |
| ksort($x); | |
| foreach ($x as $k => $v) { | |
| ksort($v); | |
| $x[$k] = $v; | |
| } | |
| ksort($y); | |
| foreach ($y as $k => $v) { | |
| ksort($v); | |
| $y[$k] = $v; | |
| } | |
| file_put_contents($argv[1] . '.res', var_export(($x), 1)); | |
| file_put_contents($argv[2] . '.res', var_export(($y), 1)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment