scossdl_string_mod() WPSCache 1.0
Compute string modulo, based on SHA1 hash
No Hooks.
Return
Int. The remainder.
Usage
scossdl_string_mod( $str, $mod );
- $str(string) (required)
- The string.
- $mod(int) (required)
- The divisor.
Code of scossdl_string_mod() scossdl string mod WPSCache 1.7.1
function scossdl_string_mod( $str, $mod ) {
/**
* The full SHA1 is too large for PHP integer types.
* This should be enough for our purpose.
*/
$num = hexdec( substr( sha1( $str ), 0, 5 ) );
return $num % $mod;
}