LimeSurvey API - Master branch

TbArray
in package

Array helper class.

Table of Contents

Methods

copyValues()  : array<string|int, mixed>
Copies the given values from one array to another.
defaultValue()  : mixed
Sets the default value for a specific key in the given array.
defaultValues()  : mixed
Sets a set of default values for the given array.
getValue()  : mixed
Returns a specific value from the given array (or the default value if not set).
merge()  : array<string|int, mixed>
Merges two arrays.
moveValues()  : array<string|int, mixed>
Moves the given values from one array to another.
popValue()  : mixed
Removes and returns a specific value from the given array (or the default value if not set).
removeValue()  : mixed
Removes a specific value from the given array.
removeValues()  : mixed
Removes a set of items from the given array.

Methods

copyValues()

Copies the given values from one array to another.

public static copyValues(array<string|int, mixed> $keys, array<string|int, mixed> $from, array<string|int, mixed> $to[, bool $force = false ]) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>

the keys to copy.

$from : array<string|int, mixed>

the array to copy from.

$to : array<string|int, mixed>

the array to copy to.

$force : bool = false

whether to allow overriding of existing values.

Return values
array<string|int, mixed>

the options.

defaultValue()

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

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

the item key.

$value : mixed

the default value.

$array : array<string|int, mixed>

the array.

defaultValues()

Sets a set of default values for the given array.

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

the default values.

$array : array<string|int, mixed>

the array to set values for.

getValue()

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

public static getValue(string $key, array<string|int, mixed> $array[, mixed $defaultValue = null ]) : mixed
Parameters
$key : string

the item key.

$array : array<string|int, mixed>

the array to get from.

$defaultValue : mixed = null

the default value.

Return values
mixed

the value.

merge()

Merges two arrays.

public static merge(array<string|int, mixed> $to, array<string|int, mixed> $from) : array<string|int, mixed>
Parameters
$to : array<string|int, mixed>

array to be merged to.

$from : array<string|int, mixed>

array to be merged from.

Return values
array<string|int, mixed>

the merged array.

moveValues()

Moves the given values from one array to another.

public static moveValues(array<string|int, mixed> $keys, array<string|int, mixed> &$from, array<string|int, mixed> $to[, bool $force = false ]) : array<string|int, mixed>
Parameters
$keys : array<string|int, mixed>

the keys to move.

$from : array<string|int, mixed>

the array to move from.

$to : array<string|int, mixed>

the array to move to.

$force : bool = false

whether to allow overriding of existing values.

Return values
array<string|int, mixed>

the options.

popValue()

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

public static popValue(string $key, array<string|int, mixed> &$array[, mixed $defaultValue = null ]) : mixed
Parameters
$key : string

the item key.

$array : array<string|int, mixed>

the array to pop the item from.

$defaultValue : mixed = null

the default value.

Return values
mixed

the value.

removeValue()

Removes a specific value from the given array.

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

the item key.

$array : array<string|int, mixed>

removeValues()

Removes a set of items from the given array.

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

the keys to remove.

$array : array<string|int, mixed>

the array to remove from.


        
On this page

Search results