<?php
use Symfony\Component\Yaml\Dumper;
$array = ['foo' =>
[
'bar' => ['1a','2b','4d','8z'],
'baz' => 'value',
]];
$yml = new Dumper();
echo '<pre>' . $yml->dump($array, 2, 4) . '</pre>';
// or you can use static
// Symfony\Component\Yaml\Yaml::dump
foo: bar: [1a, 2b, 4d, 8z] baz: value