3
How could I do to convert data yaml
in a array
of PHP?
Yaml example:
Usuario:
nome: Wallace
idade: 25
linguagens:
- PHP
- Python
- Javascript
3
How could I do to convert data yaml
in a array
of PHP?
Yaml example:
Usuario:
nome: Wallace
idade: 25
linguagens:
- PHP
- Python
- Javascript
5
A good way would be using the Yaml Component
of Symphony
.
Behold:
use Symfony\Component\Yaml\Parser;
$yaml = new Parser();
$value = $yaml->parse(file_get_contents('/arquivo.yml'));
Reference: The Yaml Component
4
In the Manual for PHP, have an example:
$yaml = <<<EOD
Usuario:
nome: Wallace
idade: 25
linguagens:
- PHP
- Python
- Javascript
EOD;
$parsed = yaml_parse($yaml);
echo "<pre>";
print_r($parsed);
Just be sure to enable the extension: extension=yaml.so
in the php.ini
To install: https://code.google.com/p/php-yaml/
For linux: http://bd808.com/pecl-file_formats-yaml/
Browser other questions tagged php array yaml
You are not signed in. Login or sign up in order to post.
+1 for the symfony
– rray
I really like the
Symphony
. It’s a pity that most systems are already written here inLaravel 4
(that’s not bad either)– Wallace Maxters