-
-
Save clytras/87c633a1465064eb993c666f16db71c7 to your computer and use it in GitHub Desktop.
Convert PHP array to YAML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"require": { | |
"symfony/yaml": "^3.2" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/php | |
<?php | |
if (php_sapi_name() !== 'cli') { | |
return; | |
} | |
date_default_timezone_set('Europe/Paris'); | |
require_once 'vendor/autoload.php'; | |
use Symfony\Component\Yaml\Yaml; | |
try { | |
$array = include('array.php'); | |
$yaml = Yaml::dump($array); | |
file_put_contents('array.yml', $yaml); | |
echo "done!\n"; | |
} catch (Exception $e) { | |
echo 'Exception: ', $e->getMessage(), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment