PHP code example of flipboxdigital / transform

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

    

flipboxdigital / transform example snippets


$raw = [
    'firstName' => 'foo',
    'lastName' => 'bar',
    'dateCreated' => new \DateTime(),
    'dateUpdated' => new \DateTime()
];

$data = Flipbox\Transform\Factory::item()
    ->transform(
        function($data) {

            return [
                'name' => [
                    'first' => $data['firstName'],
                    'last' => $data['firstName']
                ],
                'date' => [
                    'created' => $data['dateCreated']->format('c'),
                    'updated' => $data['dateUpdated']->format('c')
                ]
            ];

        },
        $raw
    );