Nimiq Roll Game

How to verify rolls results

A roll number can verify with code below

function verify(hash,block_height,lessthan) {
 $Block = block_height;
 $Hash = hash;

 $number = bchexdec($Hash);

 $digits = str_split($number);

 $sum = 0;

 foreach ($digits as $digit) {
  $sum += $digit;
 }

 $roll = $Block / $sum;
 if ($roll < lessthan){
  echo "You Win!";
 }else{
  echo "You Lose";
 }
}