\TbArray

Array helper class.

Summary

Methods
Properties
Constants
getValue()
popValue()
defaultValue()
defaultValues()
removeValue()
removeValues()
copyValues()
moveValues()
merge()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getValue()

getValue(string $key, array $array, mixed $defaultValue) : mixed

Returns a specific value from the given array (or the default value if not set).

Parameters

string $key

the item key.

array $array

the array to get from.

mixed $defaultValue

the default value.

Returns

mixed —

the value.

popValue()

popValue(string $key, array $array, mixed $defaultValue) : mixed

Removes and returns a specific value from the given array (or the default value if not set).

Parameters

string $key

the item key.

array $array

the array to pop the item from.

mixed $defaultValue

the default value.

Returns

mixed —

the value.

defaultValue()

defaultValue(string $key, mixed $value, array $array)

Sets the default value for a specific key in the given array.

Parameters

string $key

the item key.

mixed $value

the default value.

array $array

the array.

defaultValues()

defaultValues(array $values, array $array)

Sets a set of default values for the given array.

Parameters

array $values

the default values.

array $array

the array to set values for.

removeValue()

removeValue(string $key, array $array)

Removes a specific value from the given array.

Parameters

string $key

the item key.

array $array

removeValues()

removeValues(array $keys, array $array)

Removes a set of items from the given array.

Parameters

array $keys

the keys to remove.

array $array

the array to remove from.

copyValues()

copyValues(array $keys, array $from, array $to, boolean $force) : array

Copies the given values from one array to another.

Parameters

array $keys

the keys to copy.

array $from

the array to copy from.

array $to

the array to copy to.

boolean $force

whether to allow overriding of existing values.

Returns

array —

the options.

moveValues()

moveValues(array $keys, array $from, array $to, boolean $force) : array

Moves the given values from one array to another.

Parameters

array $keys

the keys to move.

array $from

the array to move from.

array $to

the array to move to.

boolean $force

whether to allow overriding of existing values.

Returns

array —

the options.

merge()

merge(array $to, array $from) : array

Merges two arrays.

Parameters

array $to

array to be merged to.

array $from

array to be merged from.

Returns

array —

the merged array.