Created
August 8, 2013 15:26
-
-
Save mamchenkov/6185612 to your computer and use it in GitHub Desktop.
Quick converter of INI files to JSON files written in PHP.
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
#!/usr/bin/php | |
<?php | |
$in = empty($argv[1]) ? '' : $argv[1]; | |
$out = empty($argv[2]) ? '' : $argv[2]; | |
if (empty($out)) { | |
$out = basename($in, '.ini') . '.json'; | |
} | |
$data = parse_ini_file($in, true); | |
$length = file_put_contents($out, json_encode($data)); | |
print "Converted $in to $out. Wrote $length bytes\n"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment