Created
February 19, 2012 17:08
-
-
Save stevenlr/1864667 to your computer and use it in GitHub Desktop.
Récupérer la liste des connectés à Orasia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Retourne un tableau JSON : ["player 1", "player 2", ...] | |
*/ | |
function get_orasia() { | |
$url = "http://188.165.212.56/mapviewer/serveur2/world/chattercraft/chatter.php"; | |
$data = file_get_contents($url); | |
$xml = simplexml_load_string(str_replace('<?xml version="1.0">', '<?xml version="1.0" ?>', $data)); | |
$list = $xml->mcserver->playerlist->player; | |
$arr = array(); | |
foreach($list as $user) { | |
$arr[] = '"'.$user.'"'; | |
} | |
$data = "[".implode(", ", $arr)."]"; | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment