ddrv/extra-pack

Extras for pack() and unpack() functions

0.9.6-beta 2018-02-15 18:25 UTC

This package is auto-updated.

Last update: 2024-11-24 03:18:49 UTC


README

Packagist Downloads License PHP

ExtraPack

Extras for pack() and unpack() functions.

Install

composer require ddrv/extra-pack
<?php
require ('vendor/autoload.php');

Usage

<?php
$data = array(
    'key1' => 'string',
    'key2' => 5,
    'key3' => .0001
);
$format = 'A6key1/Ckey2/t4key3';
$binary = \Ddrv\Extra\Pack::pack($format, $data);
$result = \Ddrv\Extra\Pack::unpack($format, $binary);
print_r($result);
Array
(
    [key1] => string
    [key2] => 5
    [key3] => .0001
)

Format

character[+number]+key[+:added]

Elements are separated by a slash

Examples:

Format characters

Currently implemented formats are: