Wrapper over array functions with a consistent interface

 Methods

Constructor

__construct(array $arr) : \PHPUtil\Arr

Parameters

$arr

array

Returns

Enable using the object as a function

__invoke(string $arr) : \PHPUtil\$this

Parameters

$arr

string

Returns

\PHPUtil\$this

Return an array with keys that are the values of the input array, and values as the frequency of those values

count_values() : array

see \PHPUtil\http://php.net/manual/function.array-count-values.php

Returns

array

Return an array with elements having the defined values

fill(int $start_index, int $num, mixed $value) : array

see \PHPUtil\http://php.net/manual/function.array-fill.php

Parameters

$start_index

int

$num

int

$value

mixed

Returns

array

Filter elements of the input array using a callback function

filter(\PHPUtil\callable $callback) : array

see \PHPUtil\http://php.net/manual/function.array-filter.php

Parameters

$callback

\PHPUtil\callable

Returns

array

Return an array with keys and values reversed from the input array

flip() : array

see \PHPUtil\http://php.net/manual/function.array-flip.php

Returns

array

Returns an array of elements from the input array that match the specified pattern

grep(mixed $pattern, mixed $invert) : array

Parameters

$pattern

mixed

$invert

mixed

Returns

array

Return the keys or a subset of the keys of an array

keys(mixed $search_value, bool $strict) : array

see \PHPUtil\http://php.net/manual/function.array-keys.php

Parameters

$search_value

mixed

$strict

bool

Returns

array

Combine arrays (Takes a variable number of arguments)

merge() : array

see \PHPUtil\http://php.net/manual/function.array-merge.php

Returns

array

Lengthen array to $pad_length with $pad_value

pad(int $pad_size, mixed $pad_value) : array

see \PHPUtil\http://php.net/manual/function.array-pad.php

Parameters

$pad_size

int

$pad_value

mixed

Returns

array

Replace elements in the main array with the values in the passed arrays (Takes a variable number of arguments)

replace() : array

see \PHPUtil\http://php.net/manual/function.array-replace.php

Returns

array

Reverse the order of the array

reverse(bool $preserve_keys) : array

see \PHPUtil\http://php.net/manual/function.array-reverse.php

Parameters

$preserve_keys

bool

Returns

array

Return a reverse-sorted array

reverse_sort(int $sort_flags) : array

see \PHPUtil\http://php.net/manual/function.asort.php

Parameters

$sort_flags

int

Returns

array

Return a sorted array

sort(int $sort_flags) : array

see \PHPUtil\http://php.net/manual/function.asort.php

Parameters

$sort_flags

int

Returns

array

Returns the sum of all the values in the array

sum() : \PHPUtil\number

see \PHPUtil\http://php.net/manual/function.array-sum.php

Returns

\PHPUtil\number

Return a new array from the original with duplicate items removed

unique($sort_flags) : array

see \PHPUtil\http://php.net/manual/function.array-unique.php

Parameters

$sort_flags

Returns

array

Returns the values from the input array with a numeric index

values() : array

Returns

array

 Properties

 

Original array to manipulate

$original : array