Dump an array to Yaml

Code
<?php

use Symfony\Component\Yaml\Dumper;

$array = ['foo' => 
    [
        
'bar' => ['1a','2b','4d','8z'],
        
'baz' => 'value',
    ]];

$yml = new Dumper();
echo 
'<pre>' $yml->dump($array24) . '</pre>';

// or you can use static 
// Symfony\Component\Yaml\Yaml::dump
Result
    foo:
        bar: [1a, 2b, 4d, 8z]
        baz: value
Used Versions
PHP 7.2, Zend 3.0, Symfony 4.0, Laravel 5.6, PHPUnit 6.5, Doctrine 2.8