PHP code example of atk14 / mini-yaml

1. Go to this page and download the library: Download atk14/mini-yaml library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

atk14 / mini-yaml example snippets


$ar = miniYAML::Load($yaml_string);

// Disable null handling — "null" is kept as a plain string
$ar = miniYAML::Load($yaml_string, ["nullable" => false]);

// Evaluate embedded PHP
$yaml = miniYAML::Load($template, [
    "interpret_php" => true,
    "values" => ["domain" => "example.com"],
]);

$yaml = miniYAML::Dump($array);

$yaml = miniYAML::Dump($array, ["nullable" => false]);

$yaml = '
---
status: success
message: Ok
data:
  domain: example.com
  admin:
  - Alice
  - Bob
  description: |
    First line.
    Second line.
';

$ar = miniYAML::Load($yaml);
// [
//   "status"  => "success",
//   "message" => "Ok",
//   "data"    => [
//     "domain"      => "example.com",
//     "admin"       => ["Alice", "Bob"],
//     "description" => "First line.\nSecond line.",
//   ]
// ]

echo miniYAML::Dump($ar);
 ...