abstract class Strings (View source)

Common String Functions

Methods

static string
shift(string $string, int $index = 1)

String Shift

static string
pop(string $string, int $index = 1)

String Pop

static mixed
unpackSSH2(string $format, string $data)

Parse SSH2-style string

static mixed
packSSH2(string[] ...$elements)

Create SSH2-style string

static string
bits2bin(string $x)

Convert binary data into bits

static string
bin2bits(string $x)

Convert bits to binary data

static string
switchEndianness(string $x)

Switch Endianness Bit Order

static string
increment_str(string $var)

Increment the current string

static bool
is_stringable(string|object $var)

Find whether the type of a variable is string (or could be converted to one)

Details

static string shift(string $string, int $index = 1)

String Shift

Inspired by array_shift

Parameters

string $string
int $index

Return Value

string

static string pop(string $string, int $index = 1)

String Pop

Inspired by array_pop

Parameters

string $string
int $index

Return Value

string

static mixed unpackSSH2(string $format, string $data)

Parse SSH2-style string

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

string $format
string $data

Return Value

mixed

static mixed packSSH2(string[] ...$elements)

Create SSH2-style string

Parameters

string[] ...$elements

Return Value

mixed

static string bits2bin(string $x)

Convert binary data into bits

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

string $x

Return Value

string

static string bin2bits(string $x)

Convert bits to binary data

Parameters

string $x

Return Value

string

static string switchEndianness(string $x)

Switch Endianness Bit Order

Parameters

string $x

Return Value

string

static string increment_str(string $var)

Increment the current string

Parameters

string $var

Return Value

string

static bool is_stringable(string|object $var)

Find whether the type of a variable is string (or could be converted to one)

Parameters

string|object $var

Return Value

bool