Faster Json data display

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SecretSquirrel
Forum Newbie
Posts: 1
Joined: Sun Jan 05, 2014 11:16 pm

Faster Json data display

Post by SecretSquirrel »

I want to make display Json data download faster on my end

Code: Select all

$ApiLink = "http://census.soe.com/get/ps2/characters_online_status/?character_id=5428029729515051201";
$json_decode = (json_decode(file_get_contents($ApiLink), true));
$status = $json_decode["characters_online_status_list"];

if (isset($status)) {
	foreach ($status as $key => $value) {
		/** STATUS
		 * ONLINE = 1
		 * OFFLINE = 0
		 */
		$status[$key] = $status[$key]["online_status"];

		echo $status[$key];
	}
}
else {
	echo "-";
}
The above page takes 1.1806 seconds to load BUT if you load this page http://census.soe.com/get/ps2/character ... 9515051201 it takes

Code: Select all

timing: {
characters_online_status-ms: 3,
total-ms: 3
}
the server is fast both are fast there should not be that much of a difference :( any tips of downloading the above information has this information in it with a var_dump();

Code: Select all

array (size=1)
  0 => 
    array (size=2)
      'character_id' => string '5428029729515051201' (length=19)
      'online_status' => string '0' (length=1)

Thanks in advance for any help! :D
Post Reply