Namespace: arr

noypiJS.arr

NOYPI arr funcs
Source:

Methods

(static) array_chunk(array, length, preserveKeysopt) → {Array}

Chunks an array into arrays with a specified number of elements.
Parameters:
Name Type Attributes Default Description
array Array The array to work on.
length number The size of each chunk.
preserveKeys boolean <optional>
false Optional. When set to true, keys will be preserved. Default is false, which will reindex the chunks numerically.
Source:
Throws:
If length is less than 1, an error will be thrown.
Type
Error
Returns:
A multidimensional numerically indexed array, starting with zero, with each dimension containing length elements.
Type
Array

(static) array_column(array, column_key, index_keyopt) → {Array}

Returns the values from a single column in the input array.
Parameters:
Name Type Attributes Default Description
array Array A multi-dimensional array or an array of objects from which to pull a column of values from. If an array of objects is provided, then public properties can be directly pulled. In order for protected or private properties to be pulled, the class must implement both the __get() and __isset() magic methods.
column_key number | string | null The column of values to return. This value may be an integer key of the column you wish to retrieve, or it may be a string key name for an associative array or property name. It may also be null to return complete arrays or objects (this is useful together with index_key to reindex the array).
index_key number | string | null <optional>
null The column to use as the index/keys for the returned array. This value may be the integer key of the column, or it may be the string key name. The value is cast as usual for array keys (however, prior to PHP 8.0.0, objects supporting conversion to string were also allowed).
Source:
Returns:
An array of values representing a single column from the input array.
Type
Array

(static) array_combine(keys, values) → {Object}

Creates an array by using the values from the keys array as keys and the values from the values array as the corresponding values.
Parameters:
Name Type Description
keys Array Array of keys to be used. Illegal values for key will be converted to string.
values Array Array of values to be used.
Source:
Throws:
If the number of elements in keys and values does not match.
Type
Error
Returns:
The combined object (associative array).
Type
Object

(static) array_diff_assoc(array, …arrays) → {Array}

Computes the difference of arrays with additional index check. Compares the first array against one or more arrays and returns the difference. Unlike array_diff(), the array keys are also used in the comparison.
Parameters:
Name Type Attributes Description
array Array The array to compare from.
arrays Array <repeatable>
Arrays to compare against.
Source:
Returns:
An array containing all the values from the first array that are not present in any of the other arrays.
Type
Array

(static) array_map(callback, …arrays) → {Array}

Applies the callback to the elements of the given arrays.
Parameters:
Name Type Attributes Description
callback function The callback function to apply to each element.
arrays Array <repeatable>
One or more arrays to apply the callback to.
Source:
Returns:
An array containing the results of applying the callback to each element.
Type
Array

(static) array_merge(…arrays) → {Array}

Merge one or more arrays.
Parameters:
Name Type Attributes Description
arrays Array <repeatable>
One or more arrays to merge.
Source:
Returns:
A merged array.
Type
Array

(static) array_merge_recursive(…arrays) → {Object}

Merge one or more arrays recursively.
Parameters:
Name Type Attributes Description
arrays Object <repeatable>
One or more arrays to merge recursively.
Source:
Returns:
A merged object with recursive merging of arrays.
Type
Object

(static) array_multisort(…arrays)

Sort multiple or multi-dimensional arrays.
Parameters:
Name Type Attributes Description
arrays Array <repeatable>
One or more arrays to sort.
Source:

(static) array_pad(array, size, value) → {Array}

Pad an array to the specified length with a value.
Parameters:
Name Type Description
array Array The array to pad.
size number The new size of the array.
value * The value to pad the array with.
Source:
Returns:
A new array padded to the specified length with the given value.
Type
Array

(static) array_pop(array) → {*}

Pop the element off the end of an array.
Parameters:
Name Type Description
array Array The array to pop from.
Source:
Returns:
The removed element.
Type
*

(static) array_product(array) → {number}

Calculate the product of values in an array.
Parameters:
Name Type Description
array Array The array to calculate the product from.
Source:
Returns:
The product of the array values.
Type
number

(static) array_push(array, …elements) → {number}

Push one or more elements onto the end of an array.
Parameters:
Name Type Attributes Description
array Array The array to push elements onto.
elements * <repeatable>
One or more elements to push onto the array.
Source:
Returns:
The new length of the array.
Type
number

(static) array_reduce(array, callback, initialValueopt) → {*}

Iteratively reduce the array to a single value using a callback function.
Parameters:
Name Type Attributes Default Description
array Array The array to reduce.
callback function A callback function to apply to each element in the array.
initialValue * <optional>
null Optional. The initial value to start the reduction with.
Source:
Returns:
The reduced value.
Type
*