PHP 8.5.0 Alpha 1 available for testing

Voting

: min(four, one)?
(Example: nine)

The Note You're Voting On

FrozenFire
14 years ago
If you need to unpack a signed short from big-endian or little-endian specifically, instead of machine-byte-order, you need only unpack it as the unsigned form, and then if the result is >= 2^15, subtract 2^16 from it.

And example would be:

<?php
$foo
= unpack("n", $signedbigendianshort);
$foo = $foo[1];
if(
$foo >= pow(2, 15)) $foo -= pow(2, 16);
?>

<< Back to user notes page

To Top