src/Gobie/Regex/Wrappers/Pcre/PcreRegex.php
public static function grep($pattern, $subject, $flags = 0)
    {
        static::setUp($pattern);
        $res = \preg_grep($pattern, (array) $subject, $flags);
        static::tearDown();
        static::handleError($pattern);

        return $res;
    }
public static function grep($pattern, $subject, $flags = 0)
    {
        static::setUp($pattern);
        $res = \preg_grep($pattern, (array) $subject, $flags);
        static::tearDown();
        static::handleError($pattern);

        return $res;
    }
Regular expression grep and return matching items.

@param string          $pattern Pattern
@param string|string[] $subject Subject or array of subjects
@param int             $flags   Flags
@return string[] Array with items that matches given pattern, empty array otherwise
@throws PcreRegexException When compilation or runtime error occurs
@link http://php.net/function.preg-grep.php