preg_grep

(PHP 4 )

preg_grep -- Return array entries that match the pattern

Description

array preg_grep (string pattern, array input)

preg_grep() returns the array consisting of the elements of the input array that match the given pattern.

Esempio 1. preg_grep() example


preg_grep("/^(\d+)?\.\d+$/", $array); // find all floating point numbers in the array
      

Nota: This function was added in PHP 4.0.