yii\helpers\BaseArrayHelper::isIn PHP Method

isIn() public static method

This method does the same as the PHP function in_array() but additionally works for objects that implement the [[\Traversable]] interface.
See also: http://php.net/manual/en/function.in-array.php
Since: 2.0.7
public static isIn ( mixed $needle, array | Traversable $haystack, boolean $strict = false ) : boolean
$needle mixed The value to look for.
$haystack array | Traversable The set of values to search.
$strict boolean Whether to enable strict (`===`) comparison.
return boolean `true` if `$needle` was found in `$haystack`, `false` otherwise.
    public static function isIn($needle, $haystack, $strict = false)
    {
        if ($haystack instanceof \Traversable) {
            foreach ($haystack as $value) {
                if ($needle == $value && (!$strict || $needle === $value)) {
                    return true;
                }
            }
        } elseif (is_array($haystack)) {
            return in_array($needle, $haystack, $strict);
        } else {
            throw new InvalidParamException('Argument $haystack must be an array or implement Traversable');
        }
        return false;
    }