$ip = "awp.bogservers.ru";
$port = "21000";
$socket = socket_create(AF_INET, SOCK_DGRAM, 0);
if( socket_connect($socket, $ip, $port) )
{
$data = "\xFF\xFF\xFF\xFF\x55\x00\x00\x00\x00";
$data = socket_read($socket,4096);
$data = ("\xFF\xFF\xFF\xFFU".substr( $data, 5, 4 ) );
socket_write( $socket, $data, strlen( $data ) );
$data = socket_read( $socket, 4096 );
$data = trim( substr( $data, 4 ) );
$i = 0;
$position = 2;
$players = [];
while( $position < strlen( $data ) )
{
$i++;
++$position;
while( $data[ $position ] != "\x00" && $position < 4000 )
$players[$i]['name'] .= $data[$position++]; //<--- вот в этой строке.
$players[$i]['score'] = ( ord( $data[ $position + 1 ] ) )
+ ( ord( $data[ $position + 2 ] ) * 256 )
+ ( ord( $data[ $position + 3 ] ) * 65536 )
+ ( ord( $data[ $position + 4 ] ) * 16777216 );
if( 2147483648 < $players[ $i ]['score'] )
$players[ $i ]['score'] -= 4294967296;
$position += 9;
}
socket_close( $socket );
} else
$result = $players = 'connection failed';