PHP code example of serima / hashee

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

    

serima / hashee example snippets




use Serima\Hashee\Hashee;

$hashForSearch = array();
Hashee::add($hashForSearch, 'super');
Hashee::add($hashForSearch, 'bad');
Hashee::add($hashForSearch, 'word');

Hashee::in('good', $hashForSearch); // false
Hashee::in('bad', $hashForSearch); // true
Hashee::release($hashForSearch);

$bannedUserNames = array('Jim', 'Taro', 'Fred');
Hashee::addBulk($bannedUserNames);
Hashee::delete($bannedUserNames, 'Fred');
Hashee::in('Jim', $bannedUserNames); // true
Hashee::in('Fred', $bannedUserNames); // false
Hashee::release($bannedUserNames);


% php tests/Benchmark.php
========================================
elementNumber : 5
in_array: 0.030714988708496
hashee:   0.013134956359863
========================================
========================================
elementNumber : 10
in_array: 0.032805919647217
hashee:   0.012555122375488
========================================
========================================
elementNumber : 100
in_array: 0.15763115882874
hashee:   0.010236978530884
========================================
========================================
elementNumber : 1000
in_array: 1.3289721012115
hashee:   0.010061025619507
========================================
========================================
elementNumber : 10000
in_array: 13.358424901962
hashee:   0.0097849369049072
========================================