← All built-ins / preg_match_all()

preg_match_all()

preg_match_all(...$args): mixed

Parameters

NameTypeDescription
$patternstring/…/ pattern
$subjectstringstring to search
$matchesarrayout-parameter: one array per matchoptional

Return value

Number of matches found; fills $matches with one sub-array per match.

Example

$m = null;
$n = preg_match_all("/\d+/", "a1 b22 c333", $m);
echo $n, " ", $m[0][0], " ", $m[0][2];
3 1 333

See also

preg_match()substr_count()