PREG_GREP(3) 1 PREG_GREP(3)
preg_grep - Return array entries that match the pattern
SYNOPSIS
array preg_grep (string $pattern, array $input, [int $flags])
DESCRIPTION
Returns the array consisting of the elements of the $input array that match the given $pattern.
PARAMETERS
o $pattern
- The pattern to search for, as a string.
o $input
- The input array.
o $flags
- If set to PREG_GREP_INVERT, this function returns the elements of the input array that do not match the given $pattern.
RETURN VALUES
Returns an array indexed using the keys from the $input array.
EXAMPLES
Example #1
preg_grep(3) example
<?php
// return all array elements
// containing floating point numbers
$fl_array = preg_grep("/^(d+)?.d+$/", $array);
?>
SEE ALSO
PCRE Patterns, preg_quote(3), preg_match_all(3), preg_filter(3), preg_last_error(3).
PHP Documentation Group PREG_GREP(3)