helpers\BaseArrayHelper remove()

remove() public static method

Removes an item from an array and returns the value. If the key does not exist in the array, the default value will be returned instead.

Usage examples,

// $array = ['type' => 'A', 'options' => [1, 2]];
// working with array
$type = \yii\helpers\ArrayHelper::remove($array, 'type');
// $array content
// $array = ['options' => [1, 2]];
public static mixed|null remove ( &$array, $key, $default = null )
$array array

The array to extract value from

$key string

Key name of the array element

$default mixed

The default value to be returned if the specified key does not exist

return mixed|null

The value of the element if found, default value otherwise

doc_Yii
2016-10-30 17:04:29
Comments
Leave a Comment

Please login to continue.