PHP code example of proteins / dictionary

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

    

proteins / dictionary example snippets


use Proteins\Dictionary;

class State extends Dictionary {}

State::set('options.use_cache',false);

State::set('users.whitelist',[
	'frank.ciccio',
	'walter.submarine',
	'pepen.spacca',
]);

echo State::get('users.whitelist.1'); // walter.submarine

print_r( State::get('a.test',['b'=>123]) ); // Array( [b] => 123 )
echo State::get('a.test.b'); // 123

$all_data = State::all();

Array (
    [users] => Array (
        [whitelist] => Array(
            [0] => frank.ciccio
            [1] => walter.submarine
            [2] => pepen.spacca
        )
    )
)

State::clear();

State::clear();
State::merge([
    'user' => [
        'name' => 'Simon',
        'role' => 'Villain',
    ],
]);

Array (
    [user] => Array (
            [name] => Simon
            [role] => Villain
        )
)

State::merge([
    'user' => [
        'name' => 'Frank',
    ],
    'happy' => true,
]);

Array (
    [user] => Array (
            [name] => Frank
            [role] => Villain
        )
    [happy] => 1
)

State::merge([
    'user' => [
        'name' => 'Frank',
    ],
    'happy' => true,
],true);

Array (
    [user] => Array (
            [name] => Simon
            [role] => Villain
        )
    [happy] => 1
)