Hey,
I followed the minequery PHP tutorial to make a status page for my minecraft server and everything works well except for 1 thing. The player names are displayed without any spaces and all on the same line.
What should i do if i wanted a <br /> between each names?
BTW here is the code i use to call the playerlist:
[syntax=php]
<font color='#ffa200'>Players: <br /><?php echo implode('', $info['playerList']);?></font>[/syntax]
Minequery PHP playerlist
Re: Minequery PHP playerlist
php.net is really useful if you're looking for information about a certain function. In this case the implode() function.
http://php.net/manual/en/function.implode.php
[syntax=text]string implode ( string $glue , array $pieces )[/syntax]
This means that the first parameter is the "glue", or whatever you want holding the words together to form a string. This could be anything. And the second parameter is the array of words you want to turn into a string.
[syntax=php]implode('<br />',$info['playerList']);[/syntax]
Easy as that.
/Edit:
Sidenote: You could loop through the names in the array and print them individually, instead of turning all of the names into a string.
[syntax=php]foreach($info['playerList'] as $name){
echo $name.'<br />';
}[/syntax]
http://php.net/manual/en/function.implode.php
[syntax=text]string implode ( string $glue , array $pieces )[/syntax]
This means that the first parameter is the "glue", or whatever you want holding the words together to form a string. This could be anything. And the second parameter is the array of words you want to turn into a string.
[syntax=php]implode('<br />',$info['playerList']);[/syntax]
Easy as that.
/Edit:
Sidenote: You could loop through the names in the array and print them individually, instead of turning all of the names into a string.
[syntax=php]foreach($info['playerList'] as $name){
echo $name.'<br />';
}[/syntax]
Re: Minequery PHP playerlist
Oh wow. you just openned my eyes! thank you for your time.