- Preg_match ( $ pattern, $ subject,[array&match]) preg_match_all ( $ Pattern, $ subject,array&matches)
Preg match matches only once and returns a value of 0 or 1; The
Preg match all matches multiple times, and how many matches to the number of times the match is returned;
$ pattern Regular expression;
$ Subject The string or array to match;
//preg_match,preg_match_all$pattern'/[0-9]/';$subject'y1jp78yn16ww55';//定义两个空数组$m1$m2array();$t1 = preg_match($pattern,$subject,$m1);//$m1输出的是一维数组;把返回值赋给$t1$t2 = preg_match_all($pattern,$subject,$m2);//$m2输出的是二维数组;把返回值赋给$t2show($m1);//使用show函数进行调试输出echo'
';show($m2);echo'
';show($t1.'||'.$t2);//匹配到的次数
Preg_match matches a maximum of one time, returning a result that is only 0 or the first match to the element, in the form of an array.
Preg_match_all all matches. The returned result may be 0 or all of the elements that match to the multidimensional array form.
'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
'). Text (i)); }; $numbering. FadeIn (1700); }); });
The above describes the regular expression of PHP match,match_all, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.