YAML

Simple YAML parser.

0 stars out of 5

00000
  • AuthorTaufik Nurrohman
  • LinkExternal URL
  • Maintainer1
  • Member
  • Version3.1.2

This extension converts YAML string to PHP data and/or PHP data to YAML string.

Usage

Convert YAML string to array:

$content = <<<YAML
key_1: value 1
key_2: value 2
key_3:
  key_3_1: value 3.1
  key_3_2: value 3.2
  key_3_3: value 3.3
key_4: |
  asdf asdf asdf
  asdf asdf asdf
YAML;

echo From::YAML($content)->key_3->key_3_3;

Convert array to YAML string:

$lot = [
    'key_1' => 'value 1',
    'key_2' => 'value 2',
    'key_3' => [
        'key_3_1' => 'value 3.1',
        'key_3_2' => 'value 3.2',
        'key_3_3' => 'value 3.3'
    ],
    'key_4' => "asdf asdf asdf\nasdf asdf asdf\n"
];

echo To::YAML($lot);

0 Comments

No comments yet.