Created
December 7, 2011 15:37
-
-
Save weaverryan/1443239 to your computer and use it in GitHub Desktop.
array rand if statements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (count($ids) == 0) { | |
return array(); | |
} | |
if (count($ids) < $ct) { | |
// careful not to request more random numbers than we have in array_rand, it will throw up | |
$randomIndexes = array_keys($ids); | |
} else { | |
$randomIndexes = array_rand($ids, $ct); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment