summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class9
1 files changed, 5 insertions, 4 deletions
diff --git a/it.class b/it.class
index 8e8be22..c537ae7 100644
--- a/it.class
+++ b/it.class
@@ -459,16 +459,17 @@ static function replace($replacements, $string, $p = array())
/**
* Returns only the array elements matching the given regex
- * @param $pattern Regex to match against
- * @param $array array to grep
+ * @param $pattern Regex to match against
+ * @param $array array to grep
+ * @param $p parameters for it::match or 'invert' => true to return non-matching lines
* @return New array
*/
static function grep($pattern, $array, $p = array())
{
if (!preg_match('/\\\\[wb]|[!\x80-\xff]|\[\[:/i', $pattern) && !$p)
- $result = preg_grep('!' . $pattern . '!i' . (ini_get('default_charset') == 'utf-8' ? 'u' : ''), $array); # fast path for simple patterns
+ $result = preg_grep('!' . $pattern . '!i' . (ini_get('default_charset') == 'utf-8' ? 'u' : ''), $array, $p['invert'] ? PREG_GREP_INVERT : 0); # fast path
else
- $result = preg_grep(it::convertregex($pattern, $p), $array);
+ $result = preg_grep(it::convertregex($pattern, $p), $array, $p['invert'] ? PREG_GREP_INVERT : 0);
return $result;
}