PageRenderTime 24ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/include/spyc/yaml-dump.php

https://github.com/radicaldesigns/amp
PHP | 36 lines | 16 code | 6 blank | 14 comment | 1 complexity | 0b9d00e019ff76680b83533f14208f85 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-3-Clause, LGPL-2.0, CC-BY-SA-3.0, AGPL-1.0
  1. <?php
  2. #
  3. # S P Y C
  4. # a simple php yaml class
  5. # v0.2(.5)
  6. #
  7. # author: [chris wanstrath, chris@ozmm.org]
  8. # websites: [http://www.yaml.org, http://spyc.sourceforge.net/]
  9. # license: [MIT License, http://www.opensource.org/licenses/mit-license.php]
  10. # copyright: (c) 2005-2006 Chris Wanstrath
  11. #
  12. # Feel free to dump an array to YAML, and then to load that YAML back into an
  13. # array. This is a good way to test the limitations of the parser and maybe
  14. # learn some basic YAML.
  15. #
  16. include('spyc.php');
  17. $array[] = 'Sequence item';
  18. $array['The Key'] = 'Mapped value';
  19. $array[] = array('A sequence','of a sequence');
  20. $array[] = array('first' => 'A sequence','second' => 'of mapped values');
  21. $array['Mapped'] = array('A sequence','which is mapped');
  22. $array['A Note'] = 'What if your text is too long?';
  23. $array['Another Note'] = 'If that is the case, the dumper will probably fold your text by using a block. Kinda like this.';
  24. $array['The trick?'] = 'The trick is that we overrode the default indent, 2, to 4 and the default wordwrap, 40, to 60.';
  25. $array['Old Dog'] = "And if you want\n to preserve line breaks, \ngo ahead!";
  26. $yaml = Spyc::YAMLDump($array,4,60);
  27. echo '<pre>A PHP array run through YAMLDump():<br/>';
  28. print_r($yaml);
  29. echo '</pre>';
  30. ?>