I would like to update some values from a YAML file. My original YAML file is:
---
theme_name: origin
meta_images: true
disqus_account: changeme
show_comments: false
globals:
-
name: phone
display: Phone
value: foo
-
name: email
display: Email
value: foo2
After reading the YAML file in using parseFile()
I get the following array in PHP:
Array
(
[theme_name] => origin
[meta_images] => 1
[disqus_account] => changeme
[show_comments] =>
[globals] => Array
(
[0] => Array
(
[name] => phone
[display] => Phone
[value] => foo
)
[1] => Array
(
[name] => email
[display] => Email
[value] => foo2
)
[phone] => foo
[email] => foo3
)
)
After updating the values I parsing it back to YAML using Symfony's YAML dump()
:
---
theme_name: origin
meta_images: true
disqus_account: changeme
show_comments: false
globals:
0:
name: phone
display: Phone
value: foo
1:
name: email
display: Email
value: foo2
phone: foo
email: foo3
I would like this to be parsed into the following YAML:
Desired YAML
---
theme_name: origin
meta_images: true
disqus_account: changeme
show_comments: false
globals:
-
name: phone
display: Phone
value: foo
-
name: email
display: Email
value: foo2
Is this possible using Symfony, or PHP's built-in YAML methods?