Mecha CMS

Convert back to X from Y.

From::YAML()

Convert YAML string into array.

2.0.02.2.0static
From::YAML($in, string $dent = '  ', $docs = false, $e = true);

Example:

$A = From::YAML('foo: bar');
$B = From::YAML(
<<<YAML
foo: bar
baz: qux
YAML
);
$C = From::YAML(
<<<YAML
---
foo: bar
baz: qux
---
foo: bar
baz: qux
...
foo bar baz
YAML
, '  ', true);

Result:

$A = ['foo' => 'bar'];
$B = [
    'foo' => 'bar',
    'baz' => 'qux'
];
$C = [
    0 => [
        'foo' => 'bar',
        'baz' => 'qux'
    ],
    1 => [
        'foo' => 'bar',
        'baz' => 'qux'
    ],
    "\t" => 'foo bar baz'
];

Related: YAML Parser