Can someone please tell me how I would add commas after the room names and user names in this piece of code. I don't want and comma after the last room name or lat user name, though, if possible.
PHP Code:
$port = 10010;
function getServerAPI( $apiCommand )
{
global $port;
$result = "";
$fp = fsockopen("localhost", $port, &$errno, &$errstr, 2);
if(!$fp)
{
echo "$errstr ($errno)\n";
}
else
{
fputs($fp,"GET /?".$apiCommand." HTTP/1.0\n\n");
$header = true;
while(!feof($fp))
{
$line = fgets($fp,128);
if ( $header == false ) $result .= $line;
if ( trim($line) == "" ) $header = false;
}
fclose($fp);
}
return $result;
}
$userList = getServerAPI( "api.UserList" );
$roomList = getServerAPI( "api.RoomList" );