src/PelConvert.php
public static function longToBytes($value, $endian)
    {
        /*
         * We cannot convert the number to bytes in the normal way (using
         * shifts and modulo calculations) because the PHP operator >> and
         * function chr() clip their arguments to 2^31-1, which is the
         * largest signed integer known to PHP. But luckily base_convert
         * handles such big numbers.
         */
        $hex = str_pad(base_convert($value, 10, 16), 8, '0', STR_PAD_LEFT);
        if ($endian == self::LITTLE_ENDIAN) {
            return (chr(hexdec($hex{6} . $hex{7})) . chr(hexdec($hex{4} . $hex{5})) . chr(hexdec($hex{2} . $hex{3})) .
                 chr(hexdec($hex{0} . $hex{1})));
        } else {
            return (chr(hexdec($hex{0} . $hex{1})) . chr(hexdec($hex{2} . $hex{3})) . chr(hexdec($hex{4} . $hex{5})) .
                 chr(hexdec($hex{6} . $hex{7})));
        }
    }
public static function longToBytes($value, $endian)
    {
        /*
         * We cannot convert the number to bytes in the normal way (using
         * shifts and modulo calculations) because the PHP operator >> and
         * function chr() clip their arguments to 2^31-1, which is the
         * largest signed integer known to PHP. But luckily base_convert
         * handles such big numbers.
         */
        $hex = str_pad(base_convert($value, 10, 16), 8, '0', STR_PAD_LEFT);
        if ($endian == self::LITTLE_ENDIAN) {
            return (chr(hexdec($hex{6} . $hex{7})) . chr(hexdec($hex{4} . $hex{5})) . chr(hexdec($hex{2} . $hex{3})) .
                 chr(hexdec($hex{0} . $hex{1})));
        } else {
            return (chr(hexdec($hex{0} . $hex{1})) . chr(hexdec($hex{2} . $hex{3})) . chr(hexdec($hex{4} . $hex{5})) .
                 chr(hexdec($hex{6} . $hex{7})));
        }
    }
public static function longToBytes ( $ value , $ endian ) { /*
         * We cannot convert the number to bytes in the normal way (using
         * shifts and modulo calculations) because the PHP operator >> and
         * function chr() clip their arguments to 2^31-1, which is the
         * largest signed integer known to PHP. But luckily base_convert
         * handles such big numbers.
         */ $ hex = str_pad ( base_convert ( $ value , 10 , 16 ) , 8 , '0' , STR_PAD_LEFT ) ; if ( $ endian == self :: LITTLE_ENDIAN ) { return ( chr ( hexdec ( $ hex { 6 } . $ hex { 7 } ) ) . chr ( hexdec ( $ hex { 4 } . $ hex { 5 } ) ) . chr ( hexdec ( $ hex { 2 } . $ hex { 3 } ) ) . chr ( hexdec ( $ hex { 0 } . $ hex { 1 } ) ) ) ; } else { return ( chr ( hexdec ( $ hex { 0 } . $ hex { 1 } ) ) . chr ( hexdec ( $ hex { 2 } . $ hex { 3 } ) ) . chr ( hexdec ( $ hex { 4 } . $ hex { 5 } ) ) . chr ( hexdec ( $ hex { 6 } . $ hex { 7 } ) ) ) ; } }
Convert an unsigned long into four bytes.

Because PHP limits the size of integers to 32 bit signed, one
cannot really have an unsigned integer in PHP. But integers
larger than 2^31-1 will be promoted to 64 bit signed floating
point numbers, and so such large numbers can be handled too.

@param integer $value
the unsigned long that will be converted. The
argument will be treated as an unsigned 32 bit integer and the
lower four bytes will be extracted. Treating the argument as an
unsigned integer means that the absolute value will be used. Use
{@link sLongToBytes} to convert signed integers.

@param boolean $endian
one of {@link LITTLE_ENDIAN} and {@link
BIG_ENDIAN}.

@return string the bytes representing the unsigned long.
Convert an unsigned long into four bytes .