PHP code example of dynoser / helml

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

    

dynoser / helml example snippets


use dynoser\HELML\HELML;  # it means that the HELML class is in the namespace "dynoser\HELML"
use dynoser\HELML\fileHELMLsect; # it means that the fileHELMLsect class is in the namespace "dynoser\HELML"

use dynoser\HELML\HELML;
e

$data = [
    "key1" => "value1",
    "key2" => [1, 2, 3],
    "key3" => [
        "nested_key" => "nested_value"
    ]
];

# Encode the data structure into a HELML string
$encoded_data = HELML::encode($data);
print_r($encoded_data)

# Decode the HELML string back into a data structure
$decoded_data = HELML::decode($encoded_data);

use dynoser\HELML\fileHELMLsect;

stdata.helml" contained this:

A:
 :X: 1
 :Y: 2
# Comment before section
B
 :X: 5
 :Y: 6

Core
 :Test: data
 :Nested key: value
C:
 # This is a Comment string
 :Other: data

DD: DD-Value
D: D-value
E: is E
F:
 :nested:
  ::--: First
  ::--: Second

*/

fileHELMLsect::$add_section_comments = false; // switch off auto-comments

$encoded_data = fileHELMLsect::Load('testdata.helml', ['B:', 'C', 'D']);

print_r($encoded_data)

$encoded_data = fileHELMLsect::Load('testdata.helml', [':nested']);

print_r($encoded_data);

(
    [nested] => Array
        (
            [0] => First
            [1] => Second
        )

)

$encoded_data = fileHELMLsect::Load('testdata.helml', [':Y'], false);

print_r($encoded_data);