<?php
$result = range(0,21);
shuffle($result);
var_dump($result);
<?php // demo/temp_eaglejess_contain.php
/**
* http://www.experts-exchange.com/questions/28938272/Can-you-tell-me-why-I-get-this-error-please.html
*
* http://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
*/
error_reporting(E_ALL);
// MAKE AN ARRAY OF UNIQUE RANDOM NUMBERS BETWEEN ZERO AND 21
$nums = range(0,21);
shuffle($nums);
// SHOW THE ARRAY
$str = implode(',', $nums);
echo $str;
<?php // demo/temp_eaglejess_contain.php
/**
* http://www.experts-exchange.com/questions/28938272/Can-you-tell-me-why-I-get-this-error-please.html
*
* http://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html
* http://php.net/manual/en/ref.array.php
*/
error_reporting(E_ALL);
// MAKE AN ARRAY OF UNIQUE RANDOM NUMBERS BETWEEN ZERO AND 21
$nums = range(0,21);
shuffle($nums);
// SHOW THE ARRAY
$str = implode(',', $nums);
echo $str;
// FIND THE LOCATION (KEY) FOR A GIVEN NUMBER
$num = 7;
$key = array_search($num, $nums);
echo PHP_EOL . "The $num is at position $key";
By removing the shuffle the numbers appear to be non random.'Zackly! :-)