In PHP, when working with YAML, is it possible to work with a specific document inside of the yaml file?
Eg
--- #settings
Settings go here
...
--- #user
Users go here
...
Is it possible to load only users into php so I can work only with that documents data?
2
Answers
use Symfony YAML Component or Spyc
It is possible. As noted in some comments, some popular libraries do not support this (Symfony YAML does not). But if you have the php YAML extension, the document number is just an additional paramenter of
yaml_parse
. Passpos
1 to load only the second document in your example.From the PHP documentation:
where: