PHP preg_grep() Function

PHP preg_grep() Function


Syntax

array preg_grep ( string $pattern, array $input [, int $flags] );

Definition and Usage

Returns the array consisting of the elements of the input array that match the given pattern.

If flag is set to PREG_GREP_INVERT, this function returns the elements of the input array that do not match the given pattern.

Return Value

  • Returns an array indexed using the keys from the input array.