int preg_match_all(string $pattern, string $source, array &$matches [, int $flags [, int $offset]])
(PHP 4, PHP 5)
| $pattern | A POSIX regular expression string. |
|---|---|
| $source | The source string to perform the match operation against. |
| $matches | The output of the regular expression match operation. |
| $flags | Options for the type of pattern matching to perform (see below). |
| $offset | Offset (character position) within the source string to start the pattern matching from. |
| RETURNS | The total number of full pattern matches found. |
Possible values for $flags
| PREG_SET_ORDER | $matches[0] contains a set of match values for the first pattern match (including all sub-matches |
|---|---|
| PREG_PATTERN_ORDER | $matches[0] contains a list of full pattern matches, $matches[1] contains a list of matches for the first parenthesized submatch expression, $matches[2] contains a list of matches for the second parenthesized submatch expressions and so on. |
Given an input array ($source) and regular expression ($pattern), this function will find matches and populate the output string ($matches). The $matches argument is passed by reference so that it can return an array with the match results. The format of this array depends on the $flags parameter which may be either: PREG_PATTERN_ORDER or PREG_SET_ORDER.