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 8.2, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8