mracine\Helpers\BinaryStringHelper is a library that provide tools to manipulate binary strings with PHP.
You can add this library as a local, per-project dependency to your project using Composer:
composer require mracine/php-binary-string
The mracine\Helpers\BinaryStringHelper is a class that provide one method :
- IntegerToNBOBinaryString static method : takes one integer parameter and returns a Network byte ordered trimed string
<?php
use mracine\Helpers\BinaryStringHelper;
// 0xFF7 => chr(0x0F).chr(0xF7)
// 0x12345678 => chr(0x12).chr(0x34).chr(0x56).chr(0x76)
// Compatible with all xx bits systems (16, 32 ...)
$networkReadyString = BinaryStringHelper::IntegerToNBOBinaryString(123456789);
// $network ready string contains chr(0x7).chr(0x5B).chr(0xCD).chr(0x15)
$networkReadyString = BinaryStringHelper::IntegerToNBOBinaryString(0x12345);
// $network ready string contains chr(0x1).chr(0x23).chr(0x45)