2017 © Pedro Peláez
 

library structphp

A port of python struct module to php

image

desean1625/structphp

A port of python struct module to php

  • Saturday, February 24, 2018
  • by desean1625
  • Repository
  • 1 Watchers
  • 2 Stars
  • 22 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

structphp

Python Struct Port to PHP for pack and unpack functions, (*1)

Install

composer require desean1625/structphp, (*2)

The module defines the following functions:, (*3)

unpack(fmt, a, p) Return an array containing values unpacked from the octet array a, beginning at position p, according to the supplied format string. If there are more octets in a than required by the format string, the excess is ignored. If there are fewer octets than required, Unpack() will return undefined. If no value is supplied for the p argument, zero is assumed., (*4)

pack(fmt, values) Return an octet array containing the packed values array. If there are more values supplied than are specified in the format string, the excess is ignored. If there are fewer values supplied, Pack() will return false. If any value is of an inappropriate type, the results are undefined. calcsize(fmt) Return the number of octets required to store the given format string. calcLength(fmt) same as calcsize, (*5)

    Format | C Type         |  Size (octets) | s
    -------------------------------------------------------------------
       A   | char[]         |     Length     
       x   | pad byte       |        1      
       c   | char           |        1       
       b   | signed char    |        1       
       B   | unsigned char  |        1       
       h   | signed short   |        2      
       H   | unsigned short |        2       
       i   | signed long    |        4      
       I   | unsigned long  |        4       
       l   | signed long    |        4      
       L   | unsigned long  |        4      
       s   | char[]         |     Length     
       f   | float          |        4      
       d   | double         |        8       
require "./vendor/audoload.php";
$struct = new Desean1625\Struct();

 print_r($struct->unpack("<2h", pack("v2", 10, 10)));//v    unsigned short (always 16 bit, little endian byte order)
 print_r($struct->unpack(">2h", pack("n2", 10, 10)));//n    unsigned short (always 16 bit, big endian byte order)
 print_r($struct->unpack(">2L", pack("N2", 10, 10)));//N    unsigned long (always 32 bit, big endian byte order)
 print_r($struct->unpack("<2L", pack("V2", 10, 10)));//V    unsigned long (always 32 bit, little endian byte order)

The Versions

24/02 2018

dev-master

9999999-dev

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

24/02 2018

dev-add-license-1

dev-add-license-1

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

07/05 2017

0.9012

0.9012.0.0

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

07/05 2017

0.9011

0.9011.0.0

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

06/05 2017

0.901

0.901.0.0

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0

 

06/05 2017

0.9

0.9.0.0

A port of python struct module to php

  Sources   Download

The Requires

  • php ^5.3.3 || ^7.0