minecraft server information tut

Ask about a PHP problem here.
Post Reply
jarrodatt
Posts: 13
Joined: Wed Sep 26, 2012 12:21 am

minecraft server information tut

Post by jarrodatt »

Hello,

Quick Question, I followed the tut to the letter I've triple checked it but I still get funky chars:


array(3) { [0]=> string(29) "SomethingCraft Public Server�" [1]=> string(2) "9�" [2]=> string(3) "100" }
mc.somethingcraft.co.uk

Status: Online

motd: SomethingCraft Public Server�

Players: 9/100

I'am getting the ? still
<?php

function fetch_server_info($ip, $port){
	$socket = @fsockopen($ip, $port, $errno, $errstr, 0.5);
	
	if($socket === false){
		return false;
	}
	
	fwrite($socket, "\xfe");

	$data = fread($socket, 256);
	
	if(substr($data, 0, 1) != "\xff"){
		return false;
	}
	
	$data = explode('§', mb_convert_encoding(substr($data, 3), 'UTF8', 'UCS-2'));
	
	return array(
		'motd' 			=> $data[0],
		'players' 		=> intval($data[1]),
		'max_players' 	=> intval($data[2]),
	);
	
}

?>
User avatar
Temor
Posts: 1186
Joined: Thu May 05, 2011 8:04 pm

Re: minecraft server information tut

Post by Temor »

try adding a dash ( - ) between UTF and 8. Or try removing UTF-2.
Post Reply