Skip to content

Instantly share code, notes, and snippets.

@levelsio
Created November 8, 2020 16:11
Show Gist options
  • Save levelsio/ad3224462f8e24c432a9700949ac7d00 to your computer and use it in GitHub Desktop.
Save levelsio/ad3224462f8e24c432a9700949ac7d00 to your computer and use it in GitHub Desktop.
<?
$followers=json_decode(file_get_contents(__DIR__.'/followers.json'),true);
echo "\n\n";
echo number_format(count($followers)).' followers';
echo "\n\n";
echo "\n\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
echo $followers[mt_array_rand($followers)]['follower']['userLink'];
echo "\n";
function mt_array_rand(Array $array, $num = 1) {
$count = count($array);
if ($num > $count) {
return null;
}
$keys = array_keys($array);
$res = [];
for ($i = 0; $i < $num;) {
$rand = mt_rand(0, $count - 1);
if (isset($res[$keys[$rand]])) {
continue;
}
$res[$keys[$rand]] = $i;
$i++;
}
$res = array_flip($res);
sort($res);
return (count($res) === 1) ? reset($res) : $res;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment