0

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

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.