Skip to content

Instantly share code, notes, and snippets.

@muskie9
Created March 1, 2017 05:04
Show Gist options
  • Save muskie9/534eeda0f0daf06cdc37e8967dc43d37 to your computer and use it in GitHub Desktop.
Save muskie9/534eeda0f0daf06cdc37e8967dc43d37 to your computer and use it in GitHub Desktop.
<?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