On Jan 23, 2008 3:38 PM, Floor Terra <floort@xxxxxxxxx> wrote: > Hi, > > Is it possible to use unpack() to read a big endian signed long > on a little endian machine? > http://nl.php.net/pack refers to perl, on wich this function is based. > The php function unpack() doesn't seem to support the "<" and ">" > modifiers like perl does. did you see this in the comments on that page? *info at dreystone dot com* 04-May-2005 02:31 <http://us.php.net/manual/en/function.unpack.php#52527> Here is my solution to reading a Big-Endian formatted double on an Little-Endian machine. <?php function ToDouble($data) { $t = unpack("C*", pack("S*", 256)); if($t[1] == 1) { $a = unpack("d*", $data); } else { $a = unpack("d*", strrev($data)); } return (double)$a[1]; } ?> -nathan