class Yaml
Yaml offers convenience methods to load and dump YAML.
static array | parse(string $input, bool $exceptionOnInvalidType = false, bool $objectSupport = false, bool $objectForMap = false) Parses YAML into a PHP array. | |
static string | dump(array $array, int $inline = 2, int $indent = 4, bool $exceptionOnInvalidType = false, bool $objectSupport = false) Dumps a PHP array to a YAML string. |
Parses YAML into a PHP array.
The parse method, when supplied with a YAML stream (string or file), will do its best to convert YAML in a file into a PHP array.
Usage:
$array = Yaml::parse(filegetcontents('config.yml'));
print_r($array);
As this method accepts both plain strings and file names as an input, you must validate the input before calling this method. Passing a file as an input is a deprecated feature and will be removed in 3.0.
Note: the ability to pass file names to the Yaml::parse method is deprecated since version 2.2 and will be removed in 3.0. Pass the YAML contents of the file instead.
Dumps a PHP array to a YAML string.
The dump method, when supplied with an array, will do its best to convert the array into friendly YAML.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Yaml/Yaml.html