Page 1 of 1

Minequery PHP playerlist

Posted: Wed Jul 04, 2012 6:46 pm
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>

Re: Minequery PHP playerlist

Posted: Wed Jul 04, 2012 8:49 pm
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 />';
}

Re: Minequery PHP playerlist

Posted: Wed Jul 04, 2012 9:08 pm
by confuz3d
Oh wow. you just openned my eyes! thank you for your time. :)

Re: Minequery PHP playerlist

Posted: Wed Jul 04, 2012 9:15 pm
by Temor
You're welcome :)