mercredi 4 octobre 2017

php array diff/range exclude returning same numbers

This function inputs a number, finds a corresponding answer value from another function, then generates numbers within several values away from the answer. It then returns 3 generated numbers and the answer as a shuffled array.

    function numbs($numb)
{
    $ans = ans($numb);
    $nums = array_diff(range(($ans - $l), ($ans + $h)), $ans);
    array_shuffle($nums);
    return array_shift (shuffle($nums[0], $nums[1], $nums[2], $ans));
}

The issue I am having is that the function will generate similar numbers not only to that of the answer variable, but numbers the same as themselves.




Aucun commentaire:

Enregistrer un commentaire