- substr: documentation ( source)
- hash: documentation ( source)
- round: documentation ( source)
- hexdec: documentation ( source)
<?php
$range = "INSERT MAX BET NUMBER"; //----------------Insert between the quotes the number of latest bet made within block 499,999
$blockhash = "INSERT HASH OF BLOCK #500.000"; //-----Insert between the quotes the hash of block number 500.000
$hash = hash('sha256', $blockhash); //--------------Create sha256 hash from block hash
$hex = substr($hash, 0, 8); //----------------------Take first 8 characters
$dec = hexdec($hex); //-----------------------------From hexadecimal to decimal number (max possible number: 4294967295)
$random = ($dec * ($range - 1)) / 4294967295; //----Reduce max possible number to $range number
$winner = round($random) + 1; //--------------------Transform number to INT and avoid number 0
echo "The winner of 0.01 BTC is the bet number: " . $winner;
?>