Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save joesexton00/0c2c0713c413bbdcb848da485f00463e to your computer and use it in GitHub Desktop.
Save joesexton00/0c2c0713c413bbdcb848da485f00463e to your computer and use it in GitHub Desktop.
PHP Weekly Challenge #51
<?php
echo superDuperRandom($argv[1], $argv[2]);
function superDuperRandom($min, $max) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://ron-swanson-quotes.herokuapp.com/v2/quotes');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
return min($min, $max) + (crc32(json_decode($data)[0]) % ($max - $min));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment