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 
'Yaml from Array:' PHP_EOL;
echo 
$yml->dump($array24);

// or you can use static 
// Symfony\Component\Yaml\Yaml::dump
Result
Yaml from Array:
foo:
bar: [1a, 2b, 4d, 8z]
baz: value