-2

How can I do to dislay players list without array?

<?php
require __DIR__ . '/MinecraftQuery.class.php';

$Query = new MinecraftQuery( );

try
{
    $Query->Connect( 'localhost', 25565 );
    $players=print_r( $Query->GetPlayers( ));

}
catch( MinecraftQueryException $e )
{
    echo $e->getMessage( );
}

?>

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • `print_r` is only for debugging purposes. It prints to the screen, and has no return value. If you pass `true` as the second value, then it'll return a string and not print anything. I think you want something like `implode(',', $Query->GetPlayers())`. – gen_Eric May 05 '14 at 18:51

1 Answers1

3

You can use implode() to create a list separated by the character(s) of your choosing:

// comma spearated
echo implode(',', $players);  
// John,Brian,Matthew

// <br> after each one but the last
echo implode('<br>', $players);
// John<br>Brian<br>Matthew
John Conde
  • 217,595
  • 99
  • 455
  • 496