Im trying to build an function that adds 5 unique numbers that match a certain value.
My snippet below does not always add 5 numbers, and it needs to be 5 unique values.
$random = [];
$val = 22;// this will be random every time
$fields = 100;
$total = 5;
for ($i = 1; $i <= $total; $i++) {
$r = rand(1,$fields);
if(!in_array($r, $random) && $r !== $val){
$random[] = $r;
}
}
return $random;
do ... whileloop.