import java.net.*;
import java.io.*;
public class URLReader {
public static void main(String[] args) throws Exception {
URL oracle = new URL("http://jsonplaceholder.typicode.com/posts");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
$stock = [
["id"=>1, "ver"=>13, "name"=>"gta v"],
["id"=>2, "ver"=>48, "name"=>"gta sa"],
["id"=>3, "ver"=>119, "name"=>"chess"],
];
$total = 0;
foreach($stock as $v) $total += $v["ver"];
$rnd = rand(1, $total);
$run = 0;
foreach($stock as $v) {
$run += $v["ver"];
if( $rnd <= $run) break;
}
$prizeName = $v["name"];