PHP code example of inpunktonet / object-flatten

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

    

inpunktonet / object-flatten example snippets



$data = [
    'company' => [
        'name' => 'InPunktoNET',
        'depth' => [
            'level' => 1,
            'level2' => [
                'level3' => 3,
            ],
        ],
    ],
];

$skeleton = new InPunktoNET\ObjectFlatten();
$skeleton->setKeyValueSeparator(';');
$skeleton->setKeySeparator('.');
echo $skeleton->toFlattenString(data: $object);

company.name;InPunktoNET
company.depth.level;1
company.depth.level2.level3;3

$flattenedStrings = [
    "company.name;InPunktoNET",
    "company.depth.level;1",
    "company.depth.level2.level3;3"
];

$skeleton = new InPunktoNET\ObjectFlatten();
$skeleton->setKeyValueSeparator(';');
$skeleton->setKeySeparator('.');

echo $skeleton->toObject(data: $object);

[
    'company' => [
        'name' => 'InPunktoNET',
        'depth' => [
            'level' => "1",
            'level2' => [
                'level3' => "3",
            ],
        ],
    ],
]