Documentation

Arr
in package

Pop utils array helper class

Tags
category

Pop

author

Nick Sagona, III dev@nolainteractive.com

copyright

Copyright (c) 2009-2024 NOLA Interactive, LLC. (http://www.nolainteractive.com)

license

http://www.popphp.org/license New BSD License

version
2.1.0

Table of Contents

Methods

collapse()  : array<string|int, mixed>
Collapse an array of arrays
divide()  : array<string|int, mixed>
Divide the array in an array of keys and values
exists()  : bool
Check if the key value exists in the array
filter()  : array<string|int, mixed>
Execute a filter callback over the values of the array
flatten()  : array<string|int, mixed>
Flatten a multi-dimensional array
isArray()  : bool
Check if the value is an array-like (array-accessible) value
isAssoc()  : bool
Check if the value is an associative (non-numeric) array
isNumeric()  : bool
Check if the value is a numeric (non-associative) array
join()  : string
Join the array values into a string
key()  : mixed
Return the key in the array based on the first position of the value
ksort()  : array<string|int, mixed>
Sort array by keys
ksortDesc()  : array<string|int, mixed>
Sort array by keys, descending
make()  : array<string|int, mixed>
Force value to be any array (if it is not one already)
map()  : array<string|int, mixed>
Execute a callable over the values of the array
prepend()  : array<string|int, mixed>
Prepend value to the array
pull()  : mixed
Pull value from the array and remove it
slice()  : array<string|int, mixed>
Return a slice of the array
sort()  : array<string|int, mixed>
Sort array
sortDesc()  : array<string|int, mixed>
Sort array descending
split()  : array<string|int, mixed>
Split a string into an array
trim()  : array<string|int, mixed>
Trim extra whitespace in the array values
uksort()  : array<string|int, mixed>
Sort array by user-defined callback using keys
usort()  : array<string|int, mixed>
Sort array by user-defined callback

Methods

collapse()

Collapse an array of arrays

public static collapse(array<string|int, mixed>|AbstractArray $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
Return values
array<string|int, mixed>

divide()

Divide the array in an array of keys and values

public static divide(array<string|int, mixed>|AbstractArray $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
Return values
array<string|int, mixed>

exists()

Check if the key value exists in the array

public static exists(array<string|int, mixed>|ArrayAccess $array, string|int $key) : bool
Parameters
$array : array<string|int, mixed>|ArrayAccess
$key : string|int
Return values
bool

filter()

Execute a filter callback over the values of the array

public static filter(array<string|int, mixed>|AbstractArray $array[, mixed $callback = null ][, int $mode = ARRAY_FILTER_USE_BOTH ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed = null
$mode : int = ARRAY_FILTER_USE_BOTH
Return values
array<string|int, mixed>

flatten()

Flatten a multi-dimensional array

public static flatten(array<string|int, mixed>|AbstractArray $array[, int|float $depth = INF ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$depth : int|float = INF
Return values
array<string|int, mixed>

isArray()

Check if the value is an array-like (array-accessible) value

public static isArray(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isAssoc()

Check if the value is an associative (non-numeric) array

public static isAssoc(array<string|int, mixed> $array) : bool
Parameters
$array : array<string|int, mixed>
Return values
bool

isNumeric()

Check if the value is a numeric (non-associative) array

public static isNumeric(array<string|int, mixed> $array) : bool
Parameters
$array : array<string|int, mixed>
Return values
bool

join()

Join the array values into a string

public static join(array<string|int, mixed>|AbstractArray $array, string $glue[, string $finalGlue = '' ]) : string
Parameters
$array : array<string|int, mixed>|AbstractArray
$glue : string
$finalGlue : string = ''
Return values
string

key()

Return the key in the array based on the first position of the value

public static key(array<string|int, mixed>|AbstractArray $array, mixed $value[, bool $strict = false ]) : mixed
Parameters
$array : array<string|int, mixed>|AbstractArray
$value : mixed
$strict : bool = false

ksort()

Sort array by keys

public static ksort(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$descending : bool = false
Return values
array<string|int, mixed>

ksortDesc()

Sort array by keys, descending

public static ksortDesc(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
Return values
array<string|int, mixed>

make()

Force value to be any array (if it is not one already)

public static make(mixed $value) : array<string|int, mixed>
Parameters
$value : mixed
Return values
array<string|int, mixed>

map()

Execute a callable over the values of the array

public static map(array<string|int, mixed>|AbstractArray $array, mixed $callback) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed
Return values
array<string|int, mixed>

prepend()

Prepend value to the array

public static prepend(array<string|int, mixed>|AbstractArray $array, mixed $value[, mixed $key = null ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$value : mixed
$key : mixed = null
Return values
array<string|int, mixed>

pull()

Pull value from the array and remove it

public static pull(array<string|int, mixed> &$array, mixed $key) : mixed
Parameters
$array : array<string|int, mixed>
$key : mixed

slice()

Return a slice of the array

public static slice(array<string|int, mixed>|AbstractArray $array, int $limit[, int $offset = 0 ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$limit : int
$offset : int = 0
Return values
array<string|int, mixed>

sort()

Sort array

public static sort(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $assoc = true ][, bool $descending = false ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$assoc : bool = true
$descending : bool = false
Return values
array<string|int, mixed>

sortDesc()

Sort array descending

public static sortDesc(array<string|int, mixed>|AbstractArray $array[, int $flags = SORT_REGULAR ][, bool $assoc = true ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$flags : int = SORT_REGULAR
$assoc : bool = true
Return values
array<string|int, mixed>

split()

Split a string into an array

public static split(string $string[, string $separator = '' ][, int|null $limit = null ]) : array<string|int, mixed>
Parameters
$string : string
$separator : string = ''
$limit : int|null = null
Return values
array<string|int, mixed>

trim()

Trim extra whitespace in the array values

public static trim(array<string|int, mixed>|AbstractArray $array) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
Return values
array<string|int, mixed>

uksort()

Sort array by user-defined callback using keys

public static uksort(array<string|int, mixed>|AbstractArray $array, mixed $callback) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed
Return values
array<string|int, mixed>

usort()

Sort array by user-defined callback

public static usort(array<string|int, mixed>|AbstractArray $array, mixed $callback[, bool $assoc = true ]) : array<string|int, mixed>
Parameters
$array : array<string|int, mixed>|AbstractArray
$callback : mixed
$assoc : bool = true
Return values
array<string|int, mixed>

        
On this page

Search results