PHP code example of taufik-nurrohman / y-a-m-l

1. Go to this page and download the library: Download taufik-nurrohman/y-a-m-l 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/ */

    

taufik-nurrohman / y-a-m-l example snippets



use function x\y_a_m_l\from as from_yaml;
use function x\y_a_m_l\to as to_yaml;

~

### Using File

Require the `from.php` and `to.php` files in your application:

~~~ php


use function x\y_a_m_l\from as from_yaml;
use function x\y_a_m_l\to as to_yaml;

 to `true`, PHP object will becomes associative array.
 * @param array $lot Currently used to store anchor(s) and custom tag(s)
 * @return mixed
 */
from(?string $value, bool $array = false, array &$lot = []): mixed;
~~~

~~~ php
/**
 * Convert PHP data to YAML string.
 *
 * @param mixed $value Your PHP data.
 * @param bool|int|string $dent Specify the indent size or character(s).
 * @return null|string
 */
to(mixed $value, bool|int|string $dent = true): ?string;
~~~

Tests
-----

Clone this repository into the root of your web server that supports PHP and then you can open the `test/from.php` and
`test/to.php` file with your browser to see the result and the performance of this converter in various cases.

Tweaks
------

Your YAML content is represented as variable `$value`. If you modify the content before the function `from_yaml()` is
called, it means that you modify the YAML content before it is converted. If you modify the content after the function
`from_yaml()` is called, it means that you modify the results of the YAML conversion.

### Globally Reusable Functions

To make `from_yaml()` and `to_yaml()` functions reusable globally, use this method:

~~~ php