I am looking for the PHP equelent to JAVA\'s
\"SomeString\".hashCode();
function. The hashCode i am looking for should be the same which is u
a utf-8 version with emoji support
function str_hashcode($s){
$hash = 0;
$len = mb_strlen($s, 'UTF-8');
if($len == 0 )
return $hash;
for ($i = 0; $i < $len; $i++) {
$c = mb_substr($s, $i, 1, 'UTF-8');
$cc = unpack('V', iconv('UTF-8', 'UCS-4LE', $c))[1];
$hash = (($hash << 5) - $hash) + $cc;
$hash &= $hash; // 16bit > 32bit
}
return $hash;
}