yii\helpers\BaseArrayHelper::removeValue PHP Метод

removeValue() публичный статический Метод

Example, php $array = ['Bob' => 'Dylan', 'Michael' => 'Jackson', 'Mick' => 'Jagger', 'Janet' => 'Jackson']; $removed = \yii\helpers\ArrayHelper::removeValue($array, 'Jackson'); result: $array = ['Bob' => 'Dylan', 'Mick' => 'Jagger']; $removed = ['Michael' => 'Jackson', 'Janet' => 'Jackson'];
С версии: 2.0.11
public static removeValue ( array &$array, string $value ) : array
$array array the array where to look the value from
$value string the value to remove from the array
Результат array the items that were removed from the array
    public static function removeValue(&$array, $value)
    {
        $result = [];
        if (is_array($array)) {
            foreach ($array as $key => $val) {
                if ($val === $value) {
                    $result[$key] = $val;
                    unset($array[$key]);
                }
            }
        }
        return $result;
    }