PHP code example of gaming-engine / dictionary

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

    

gaming-engine / dictionary example snippets


$dict = new \GamingEngine\Dictionary\Dictionary();

$dict[new \stdClass()] = 12;
$dict['php'] = 23;
$dict[100] = 'dictionary';

$dict = new \GamingEngine\Dictionary\Dictionary();

$dict = \GamingEngine\Dictionary\Dictionary::fromPairs([
    ['key1', 'value1'],
    ['key2', 'value2'],
    ['key3', 'value3'],
]);

$dict = \GamingEngine\Dictionary\Dictionary::fromArray([
    'key1' => 'value1',
    'key2' => 'value2',
    'key3' => 'value3',
]);

$dictionary->sortBy('values','asc');

$dictionary->sortBy(function($value, $key) {
    return $value->title . $key->name;
}, 'desc');

$sortedDictionary = $dictionary->getCopy()->sortBy('values', 'asc');