$ Str & amp; #39; sdfasfs12333ddd12233 & amp; #39; preg_match (& amp; #39;/\ d/si & amp; #39 ;, $ str, $ arr); // find three consecutive numbers echo & amp; #39; & lt; pre & gt; & amp; #39 ;; print_r ($ arr); echo & am
$ Str = 'sdfasfs12333ddd12233 ';
Preg_match ('/\ d/si', $ str, $ arr); // you can specify three consecutive numbers.
Echo'
';print_r($arr);
echo '
';
1. This function only matches the first value.
2. $ Arr [0] stores the result.
Preg_match_all all results, so it is a two-dimensional array: $ arr [0] [1] stores the first result, $ arr [0] [n] stores the nth result;
$ Arr [1] [0] stores the results of the first subexpression in the first result. $ arr [1] [n] stores the results of n + 1, the result of the first subexpression;
Example: The most commonly used knowledge point during wei's static state
$ Str = "111-555-666 dfs5 + fsfffsd-2215affsfsdf ";
Preg_match ('/(\ d) \ 1 {2}-(\ d) \ 2 {2}-(\ d) \ 3 {2}/Si', $ str, $ arr); // you must use 'and cannot use' Because reverse capture exists.
Second: http: // localhost/wc. php/15,23,45.html:
Method 1: Use a regular table for processing in php; $ _ SERVER [PATH_INFO];
$ Para = $ _ SERVER ['path _ info'];
$ Pattern = '/(\ d) +/si'; // There is a number
$ Pattern = '// (\ d +), (\ d +), (\ d +) \. html $/si ';
Preg_match ($ pattern, $ para, $ arr );
Method 2: Use apache rewrite for processing.