Я думаю, что получил его на работу, и я многому научился! :)
<?php
//Get the current timestamp
$url = 'http://www.epgpweb.com/api/snapshot/us/Caelestrasz/Crimson';
$url = file_get_contents($url);
$url = substr($url,-12,10);
//Get the member data based on the timestamp
$url = 'http://www.epgpweb.com/api/snapshot/us/Caelestrasz/Crimson/'.$url;
$url = file_get_contents($url);
//Convert the unicode to html entities, as I found here: /1715980/kak-dekodirovat-escape-posledovatelnosti-unicode-takie-kak-u00ed-v-sootvetstvuyschie-simvoly-v-kodirovke-utf-8
function replace_unicode_escape_sequence($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
}
$url = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $url);
//erase/replace the insignificant parts, to put the data into an array
function erase($a){
global $url;
$url = explode($a,$url);
$url = implode("",$url);
}
function replace($a,$b){
global $url;
$url = explode($a,$url);
$url = implode($b,$url);
}
replace("[[",";");
replace("]]",";");
replace("],",";");
erase('[');
erase('"');
replace(":",",");
$url = explode(";", $url);
//lose the front and end bits, and maintain the member data
array_shift($url);
array_pop($url);
//put the data into an array
foreach($url as $k=>$v){
$v = explode(",",$v);
foreach($v as $k2=>$v2){
$data[$k][$k2] = $v2;
}
$pr = round(intval($data[$k][1]) / intval($data[$k][2]),3);
$pr = str_pad($pr,5,"0",STR_PAD_RIGHT);
$pr = substr($pr, 0, 5);
$data[$k][3] = $pr;
}
//sort the array by PR number
function compare($x, $y)
{
if ( $x[3] == $y[3] )
return 0;
else if ( $x[3] > $y[3] )
return -1;
else
return 1;
}
usort($data, 'compare');
//output the data into a table
echo "<table><tbody><tr><th>Member</th><th>EP</th><th>GP</th><th>PR</th></tr>";
foreach($data as $k=>$v){
echo "<tr>";
foreach($v as $v2){
echo "<td>".$v2."</td>";
}
echo "</tr>";
}
echo "</tbody></table>";
?>