PHP code example of pigeonboys / php-binary-parser
1. Go to this page and download the library: Download pigeonboys/php-binary-parser library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pigeonboys / php-binary-parser example snippets
use PigeonBoys\PhpBinaryParser\BinaryParser;
$buffer = [0x12, 0x34, 0x56, 0x78];
$parser = new BinaryParser($buffer);
// Read an unsigned 16-bit integer in big-endian
$value = $parser->int16()->unsigned()->bigEndian()->read();
echo $value; // 4660
// After this read, the first two bytes are removed from the buffer
echo $parser->bytesRemaining(); // 2
$parser = new BinaryParser([0x01, 0x02, 0x03, 0x04]);
// Read two unsigned 8-bit integers
$values = $parser->int8()->unsigned()->readMany(2);
print_r($values); // [1, 2]
// Only remaining bytes are left in the buffer
echo $parser->bytesRemaining(); // 2
$parser->resetBuffer(); // restores all original bytes
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.