PHP preg_match and preg_match_all functions

sikas picture sikas · Nov 3, 2010 · Viewed 45.1k times · Source

I would like to know what the preg_match and preg_match_all functions do and how to use them.

Answer

romaninsh picture romaninsh · Nov 4, 2013

preg_match stops looking after the first match. preg_match_all, on the other hand, continues to look until it finishes processing the entire string. Once match is found, it uses the remainder of the string to try and apply another match.

http://php.net/manual/en/function.preg-match-all.php