Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
<?php
function rand_except($min, $max, $except)
//function returns a random integer between min and max, just like function rand() does.
// Difference to rand is that the random generated number will not use any of the values
// placed in $except. ($except must therefore be an array)
// function returns false if $except holds all values between $min and $max.
{
//first sort array values
sort($except, SORT_NUMERIC);
//calculate average gap between except-values
$except_count = count($except);
$avg_gap = ($max - $min + 1 - $except_count) / ($except_count + 1);
if ($avg_gap <= 0)
return false;
//now add min and max to $except, so all gaps between $except-values can be calculated
array_unshift($except, $min - 1);
array_push($except, $max + 1);
$except_count += 2;
//iterate through all values of except. If gap between 2 values is higher than average gap,
// create random in this gap
for ($i = 1; $i < $except_count; $i++)
if ($except[$i] - $except[$i - 1] - 1 >= $avg_gap)
return mt_rand($except[$i - 1] + 1, $except[$i] - 1);
return false;
}
?>
$unallowedValues = array(3,5);
while(true)
{
$num = mt_rand(1,6);
if(!in_array($num,$unallowedValues)) break;
}
function rand_except($min, $max, $except){
$except = array_unique($except, SORT_NUMERIC);
sort($except, SORT_NUMERIC);
$len = count($except);
$rand = mt_rand($min, $max - $len);
for ($i = 0; $i < $len && $except[$i] <= $rand; $i++){
$rand++;
}
return $rand;
}