Reputation: 9937
I have one YAML file like this
category: 'test'
available: true
class: true
name: 'john'
children:
-
id: fdfd5
f2: 30
Now before that name field i want to add one more file like
displayname = This is your $name
where $name is name from same category.
This is what i am thinkling of
//read
$yaml = Yaml::parse(file_get_contents('/path/to/file.yml'));
//code here
//write
$dumper = new Dumper();
$yaml = $dumper->dump($array);
file_put_contents('/path/to/file.yml', $yaml);
How can i get $array to what i want
Upvotes: 0
Views: 1516
Reputation: 105878
Uh, I think this will work (don't have a VM nearby so I can't test it)
$yaml = array_merge(
array('displayname' => "This is your $name")
, Yaml::parse(file_get_contents('/path/to/file.yml'))
);
file_put_contents('/path/to/file.yml', Yaml::dump($yaml));
Or you could always make your own configuration class
Upvotes: 1