Strings
in package
Common String Functions
Tags
Table of Contents
Methods
- bin2bits() : string
- Convert bits to binary data
- bits2bin() : string
- Convert binary data into bits
- increment_str() : string
- Increment the current string
- is_stringable() : bool
- Find whether the type of a variable is string (or could be converted to one)
- packSSH2() : mixed
- Create SSH2-style string
- pop() : string
- String Pop
- shift() : string
- String Shift
- switchEndianness() : string
- Switch Endianness Bit Order
- unpackSSH2() : mixed
- Parse SSH2-style string
- formatPack() : string
- Expand a pack string
Methods
bin2bits()
Convert bits to binary data
public
static bin2bits(string $x) : string
Parameters
- $x : string
Tags
Return values
stringbits2bin()
Convert binary data into bits
public
static bits2bin(string $x) : string
bin2hex / hex2bin refer to base-256 encoded data as binary, whilst decbin / bindec refer to base-2 encoded data as binary. For the purposes of this function, bin refers to base-256 encoded data whilst bits refers to base-2 encoded data
Parameters
- $x : string
Tags
Return values
stringincrement_str()
Increment the current string
public
static increment_str(string &$var) : string
Parameters
- $var : string
Tags
Return values
stringis_stringable()
Find whether the type of a variable is string (or could be converted to one)
public
static is_stringable(string|object $var) : bool
Parameters
- $var : string|object
Tags
Return values
boolpackSSH2()
Create SSH2-style string
public
static packSSH2(array<string|int, string> ...$elements) : mixed
Parameters
- $elements : array<string|int, string>
Tags
pop()
String Pop
public
static pop(string &$string[, int $index = 1 ]) : string
Inspired by array_pop
Parameters
- $string : string
- $index : int = 1
Tags
Return values
stringshift()
String Shift
public
static shift(string &$string[, int $index = 1 ]) : string
Inspired by array_shift
Parameters
- $string : string
- $index : int = 1
Tags
Return values
stringswitchEndianness()
Switch Endianness Bit Order
public
static switchEndianness(string $x) : string
Parameters
- $x : string
Tags
Return values
stringunpackSSH2()
Parse SSH2-style string
public
static unpackSSH2(string $format, string &$data) : mixed
Returns either an array or a boolean if $data is malformed.
Valid characters for $format are as follows:
C = byte b = boolean (true/false) N = uint32 s = string i = mpint L = name-list
uint64 is not supported.
Parameters
- $format : string
- $data : string
formatPack()
Expand a pack string
private
static formatPack(string $format) : string
Converts C5 to CCCCC, for example.
Parameters
- $format : string