Skip to content

Instantly share code, notes, and snippets.

@gloryofrobots
Last active August 29, 2015 14:25
Show Gist options
  • Save gloryofrobots/cd667f41cc02d8d19c91 to your computer and use it in GitHub Desktop.
Save gloryofrobots/cd667f41cc02d8d19c91 to your computer and use it in GitHub Desktop.
dijkstra hash in php
function myhash($str) {
$result = 5381;
for($i=0; $i<strlen($str); $i++) {
$c = (int) $str[$i];
$result = (($result << 5) + $result) + $c;
}
return $result;
}
$str = "aabbcc";
echo "Hash for ".$str." = ". myhash($str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment