For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2004 > Re: [PHP-DB] preg_math vs preg_match_all









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] preg_math vs preg_match_all
Gerard Samuel

2004-11-23, 3:56 pm

Yemi Obembe wrote:

>Just want to know the difference between preg_match and preg_match_all.
>

preg_match stops after the first match.
preg_match_all gets *all* the matches.

E.g. If you have a string -> $str = "foofoo";
preg_match('/foo/', $str, $match); -> $match will have an array with one
"foo".
preg_match_all('/foo/', $str, $match); -> $match will have an array with
two "foo".

Thats basically it.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com