yaml-dump.php 974 B

12345678910111213141516171819202122232425
  1. <?php
  2. #
  3. # S P Y C
  4. # a simple php yaml class
  5. #
  6. # Feel free to dump an array to YAML, and then to load that YAML back into an
  7. # array. This is a good way to test the limitations of the parser and maybe
  8. # learn some basic YAML.
  9. #
  10. include('../Spyc.php');
  11. $array[] = 'Sequence item';
  12. $array['The Key'] = 'Mapped value';
  13. $array[] = array('A sequence','of a sequence');
  14. $array[] = array('first' => 'A sequence','second' => 'of mapped values');
  15. $array['Mapped'] = array('A sequence','which is mapped');
  16. $array['A Note'] = 'What if your text is too long?';
  17. $array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block. Kinda like this.';
  18. $array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.';
  19. $array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!";
  20. $array['key:withcolon'] = "Should support this to";
  21. $yaml = Spyc::YAMLDump($array,4,60);