ddrv/extra-pack

pack() 和 unpack() 函数的额外功能

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

This package is auto-updated.

Last update: 2024-08-24 02:48:59 UTC


README

Packagist Downloads License PHP

ExtraPack

pack() 和 unpack() 函数的额外功能。

安装

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

用法

<?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
)

格式

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

元素由斜杠分隔

示例

格式字符

当前实现的格式有