I have some PHP code that grabs data from JSON. The code retruns all the usernames, including the current username to display. My question is, how would I only allow it so that it only shows the recent usernames and not the current?
I am using the Minecraft API for this and the JSON code I am getting can be found here.
Note that
_scrunch
is the current username.
Here's my code that displays the names:
// Save the uuid
$uuid = $json->id;
// Get the history (using $json->uuid)
$content = file_get_contents('https://api.mojang.com/user/profiles/' . urlencode($uuid) . '/names');
// Decode it
$json = json_decode($content);
$names = array(); // Create a new array
foreach ($json as $name) {
$input = $name->name;
if (!empty($name->changedToAt)) {
// Convert to YYYY-MM-DD HH:MM:SS format
//do
// $input .= ' (changed at ' . $time . ')';
}
$names[] = $input; // Add each "name" value to our array "names"
}
and to display it
<?php echo implode(', ', $names) ;?>
Any help would be great! Thanks!