scossdl_string_mod() WPSCache 1.0
Compute string modulo, based on SHA1 hash
Хуков нет.
Возвращает
Число. The remainder.
Использование
scossdl_string_mod( $str, $mod );
- $str(строка) (обязательный)
- The string.
- $mod(число) (обязательный)
- The divisor.
Код 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;
}