Skip to content

Instantly share code, notes, and snippets.

@shinofara
Created April 12, 2013 10:19
Show Gist options
  • Save shinofara/5371060 to your computer and use it in GitHub Desktop.
Save shinofara/5371060 to your computer and use it in GitHub Desktop.
需要は無いかもしれないが、ini形式をyaml形式に変換する処理を書いてみた。 ref: http://qiita.com/items/12cc1bf4b6e1c4ec5703
<?php
$ini = parse_ini_file($_SERVER['argv'][1],true);
foreach($ini as $section => $conf){
echo $section,":\n";
//sction内ループ
foreach($conf as $key => $val){
if(is_array($val)){
echo " ",$key,":\n";
foreach($val as $num => $file){
echo " - ",$file,"\n";
}
}
else {
echo " ",$key,": ",$val,"\n";
}
}
}
?>
php trance.php test.ini > test.yml
test:
name: value
age: 12
test:
- test1
- test2
test2:
name: value
age: 12
test:
- test1
- test2
[test]
name=value
age=12
test[]=test1
test[]=test2
[test2]
name=value
age=12
test[]=test1
test[]=test2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment