I have not done this before with PHP, but first I assume that you will get the binary string back, which you will need to convert to ASCII (or any other character set that you use).
It looks like you should use PHP unpack for this.
, , , . , , , ( , ), ASCII, chr. :
//Receive some data
$r = socket_recvfrom($sock, $buf, 512, 0, $remote_ip, $remote_port);
//Convert to array of decimal values
$array = unpack("c*chars", $buf);
//Convert decimal values to ASCII characters:
$chr_array = array();
for ($i = 0; $i < count($array); $i++)
{
$chr_array[] = chr($array[$i]);
}
, (.. ..). ).
EDIT: , , 'chars' .
EDIT: ASCII .