I am creating a section for sponsored servers and I would like to create the following:
A table, showing the sponsored servers, which should be classified from highest to lowest in a table. They will be classified depending on the number of votes each one has, and the first one that appears in the table must have the <tr class="success">
tag, while the others must have the <tr>
tag.
The sponsored-servers.json file stores 3 sponsored servers in JSON format.
The all-servers-json file contains many more servers including the sponsored servers, and for each one there is a VOTOS
key that contains an integer number of server votes. Sponsored servers must be organized from highest to lowest thanks to the number of votes of each .
I tried using the following PHP code:
<?php foreach(json_decode(file_get_contents('servidores-patrocinados.json')) as $servidor_patrocinado) {
if(!max((arsort(json_decode(file_get_contents('todos-los-servidores.json')))['VOTOS'] == $servidor_patrocinado)) continue; //Continuar al siguiente foreach, el primero necesita ser el con más votos
}
?>
And it has not worked for me.
File structure
servers-sponsored.json :
[
{
"NAME": "Aphmau Craft",
"MCPE_LIST": "minecraftpocket-servers.com",
"ALIAS": "Aphmau"
},
{
"NAME": "CCPvP",
"MCPE_LIST": "minecraftpocket-servers.com",
"ALIAS": "Vote"
},
{
"NAME": "OPMCPE",
"MCPE_LIST": "minecraftpocket-servers.com",
"ALIAS": "r8i5"
}
]
all-the-servers.json : (There are many more):
[
{
"MCPE_LIST": "minecraftpocket-servers.com",
"URL": "https:\/\/minecraftpocket-servers.com\/server\/62849\/vote\/",
"PREMIUM": false,
"ALIAS": "5hv7",
"VOTES": 6,
"SERVER_NAME": "DateCraftRP",
"PASSWORD": "$2y$10$UVFMjTy4EtlkN3NFpFhRHOis..EKk5mg5GfpCkcDzO5EERh0kQ3jq"
},
{
"MCPE_LIST": "minecraftpocket-servers.com",
"URL": "https:\/\/minecraftpocket-servers.com\/server\/64455\/",
"PREMIUM": false,
"ALIAS": "Aphmau",
"VOTES": 284,
"SERVER_NAME": "Aphmau Craft!",
"PASSWORD": "$2y$10$xsjwMaheRlfhx.5MXOdFPOJLmEIPlCi12ONWQIXrjxtVVlkW5LYRC"
},
{
"MCPE_LIST": "minecraftpocket-servers.com",
"URL": "https:\/\/minecraftpocket-servers.com\/server\/49063",
"PREMIUM": false,
"ALIAS": "Ashcraft",
"VOTES": 0,
"SERVER_NAME": "AshcraftPE",
"PASSWORD": "$2y$10$1K2o79HQ52dDs\/KxZ1kH0.ogTWyRZvBa02qg5DgqNlfZmfQhMGr8m"
}
]
By the way, the ALIAS
is used to differentiate one server from another.