Documentation

Arrays
in package

Table of Contents

Methods

allUniqueSortedCombinations()  : array<string|int, mixed>
Returns an array of all k-combinations from an input array of n elements, where k equals 1..n.
combinations()  : array<string|int, mixed>
Returns an array of unique k-combinations from an input array.
get()  : mixed
uniqueRecursiveMerge()  : array<string|int, mixed>
Merge arrays recursively, appending integer-like keys and merge string keys.

Methods

allUniqueSortedCombinations()

Returns an array of all k-combinations from an input array of n elements, where k equals 1..n.

public static allUniqueSortedCombinations(array<string|int, mixed> $array[, int|null $maxSize = null ]) : array<string|int, mixed>

Elements will be sorted and unique in every combination.

Example: array[one, two] will give: [ [one], [two], [one, two] ]

Parameters
$array : array<string|int, mixed>
$maxSize : int|null = null

Max depth of the combinations

Return values
array<string|int, mixed>

combinations()

Returns an array of unique k-combinations from an input array.

public static combinations(array<string|int, mixed> $array, int $k) : array<string|int, mixed>

Example: array=[one, two, three] and k=2 will give: [ [one, two], [one, three] ]

Parameters
$array : array<string|int, mixed>
$k : int
Return values
array<string|int, mixed>

get()

public static get(mixed $array, mixed $key[, mixed $default = null ]) : mixed
Parameters
$array : mixed
$key : mixed
$default : mixed = null

uniqueRecursiveMerge()

Merge arrays recursively, appending integer-like keys and merge string keys.

public static uniqueRecursiveMerge(array<string|int, mixed> ...$arrays) : array<string|int, mixed>
Parameters
$arrays : array<string|int, mixed>

Arrays to merge

Return values
array<string|int, mixed>

Merged array


        
On this page

Search results