Created
March 1, 2017 05:04
-
-
Save muskie9/534eeda0f0daf06cdc37e8967dc43d37 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
public function getRandom($count = 2) | |
{ | |
$records = self::get()->column(); | |
$filter = array(); | |
$have = 0; | |
while(count($filter) < 2){ | |
$rand = array_rand($records); | |
if(!in_array($rand, $filter)){ | |
$filter[$rand] = $rand; | |
} | |
} | |
return self::get()->filter( | |
array( | |
'ID' => $filter | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment