PHP code example of ivopetkov / data-object

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

    

ivopetkov / data-object example snippets


use \IvoPetkov\DataList;

$data = [
    ['value' => 'a'],
    ['value' => 'b'],
    ['value' => 'c']
];
$list = new DataList($data);

// Can access the objects by index and get properties the following ways
echo $list[0]->value; // Output: a
echo $list[1]->value; // Output: b

// Can loop through the objects
foreach($list as $object){
    echo $object->value;
}


use \IvoPetkov\DataList;

$list = new DataList([...]);
$list
    ->filterBy('property1', '...')
    ->sortBy('property2')
    ->map(function($object){});