Mecha CMS

Add extra functionality to the core engine.

YAML

Table of Contents
  1. Usage 

Simple YAML parser that converts YAML string into key-value pairs and array input into YAML string.

Usage 

Convert YAML string to array:

$content = <<<YAML
a: b
c:
  d: e
  f: g
h: 1
i: [j, k, l]
m:
  - n
  - o
  - p
YAML;

echo From::YAML($content)['c']['d'];

Convert array to YAML string:

$data = [
    'a' => 'b',
    'c' => [
        'd' => 'e',
        'f' => 'g'
    ],
    'h' => 1,
    'i' => ['j', 'k', 'l'],
    'm' => ['n', 'o', 'p']
];

echo To::YAML($data);