Skip to content

Instantly share code, notes, and snippets.

@kuldipem
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuldipem/252fb761ad5a70e5a09b to your computer and use it in GitHub Desktop.
Save kuldipem/252fb761ad5a70e5a09b to your computer and use it in GitHub Desktop.
get unique values within range
<?php
function getUniqeValueWithinRang($count=10,$min=0,$max=10){
$uniqValuesInRange=[];
for($j=0;$j<$count;$j++){
$ran=rand($min,$max);
while(in_array($ran=rand($min,$max), $uniqValuesInRange));
array_push($uniqValuesInRange, $ran);
}
return $uniqValuesInRange;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment