PHP code example of originphp / yaml

1. Go to this page and download the library: Download originphp/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/ */

    

originphp / yaml example snippets


use Origin\Yaml\Yaml;
$employees = [
    ['name'=>'Jim','skills'=>['php','mysql','puppeteer']],
    ['name'=>'Amy','skills'=>['ruby','ruby on rails']],
];
$yaml = Yaml::fromArray($employees );

 $bookmark = $this->Bookmark->get(1,[
            'associated'=>[
                'User','Tag'
                ]
            ]);
$string = Yaml::fromArray($bookmark->toArray()); 


$employee =  'name: Tom
position: developer
skills:
    - php
    - mysql
    - js
addresses:
    - street: 14 some road
      city: london
    - street: 21 some avenue
      city: leeds
summary:
    this is a text description
    for this employee';
$array = Yaml::toArray($employee);
/*
Array
(
    [name] => Tom
    [position] => developer
    [skills] => Array
        (
            [0] => php
            [1] => mysql
            [2] => js
        )

    [addresses] => Array
        (
            [0] => Array
                (
                    [street] => 14 some road
                    [city] => london
                )

            [1] => Array
                (
                    [street] => 21 some avenue
                    [city] => leeds
                )

        )

    [summary] => this is a text description for this employee
)
*/