Minequery PHP playerlist

Post here is you are having problems with any of the tutorials.
Post Reply
confuz3d
Posts: 2
Joined: Wed Jul 04, 2012 5:40 pm

Minequery PHP playerlist

Post by confuz3d »

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:
<font color='#ffa200'>Players: <br /><?php echo implode('', $info['playerList']);?></font>
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Minequery PHP playerlist

Post by Temor »

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
string implode ( string $glue , array $pieces )
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.
implode('<br />',$info['playerList']);
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.
foreach($info['playerList'] as $name){
echo $name.'<br />';
}
confuz3d
Posts: 2
Joined: Wed Jul 04, 2012 5:40 pm

Re: Minequery PHP playerlist

Post by confuz3d »

Oh wow. you just openned my eyes! thank you for your time. :)
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: Minequery PHP playerlist

Post by Temor »

You're welcome :)
Post Reply