Advertisement
Guest User

Untitled

a guest
Feb 16th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. function make()
  2. {
  3.     return $newVocabulary = [];
  4. }
  5.  
  6. function set(&$map, $key, $value)
  7. {
  8.     $hash = crc32($key) % 1000;
  9.  
  10.     if (array_key_exists($hash, $map)) {
  11.         return false;
  12.     }
  13.  
  14.     $map[$hash][1] = $value;
  15.  
  16.     return true;
  17. }
  18.  
  19. function get(&$map, $key, $default = null)
  20. {
  21.     $hash = crc32($key) % 1000;
  22.  
  23.     if (!array_key_exists($hash, $map)) {
  24.         return 'null';
  25.     }
  26.  
  27.     $heshResult = $map[$hash];
  28.     $value = $heshResult[1];
  29.     return $value === $default ? $value : 'null';
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement