Skip to content

Instantly share code, notes, and snippets.

@zbskii
Last active January 2, 2016 18:39
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 zbskii/8345434 to your computer and use it in GitHub Desktop.
Save zbskii/8345434 to your computer and use it in GitHub Desktop.
function bal(){
$serversNew = array();
$servers = array("host1", "host2", "host3", "host4");
$query = "give me all the";
$numServers = count($servers);
while($numServers > 0) {
$key = hexdec(substr(md5($numServers . '+' . $query),0,4))%($numServers);
$keySet = array_keys($servers);
$serverId = $keySet[$key];
array_push($serversNew, $servers[$serverId]);
unset($servers[$serverId]);
--$numServers;
print "serversNew: " . print_r($serversNew, true);
}
}
bal();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment