PHP code example of kosatyi / datamodel

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

    

kosatyi / datamodel example snippets


    use Kosatyi\DataModel as Model;
    $model = new Model();
    $model->data([
        'prop' => 'value',
        'list' => [
            'item0','item1','item2'
        ],
        'map'  = [
            'prop1'=> 'value1',
            'prop2'=> 'value2' 
        ]
    ]);
    echo $model->attr('prop1');
    echo $model->attr('list.0');
    echo $model->attr('map.prop1');
    $model->attr('list.1','item1-changed');
    $model->attr('prop','value-changed');
    $model->attr('map.prop2','value2');