1--TEST--
2Test preg_match_all() function : basic functionality
3--FILE--
4<?php
5/*
6* Function is implemented in ext/pcre/php_pcre.c
7*/
8$string = 'Hello, world! This is a test. This is another test. \[4]. 34534 string.';
9var_dump(preg_match_all('/[0-35-9]/', $string, $match1, PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER, -10)); //finds any digit that's not 4 10 digits from the end(1 match)
10var_dump($match1);
11var_dump(preg_match_all('/[tT]his is a(.*?)\./', $string, $match2, PREG_SET_ORDER)); //finds "This is a test." and "This is another test." (non-greedy) (2 matches)
12var_dump($match2);
13var_dump(preg_match_all('@\. \\\(.*).@', $string, $match3, PREG_PATTERN_ORDER)); //finds ".\ [...]" and everything else to the end of the string. (greedy) (1 match)
14var_dump($match3);
15var_dump(preg_match_all('/\d{2}$/', $string, $match4)); //tries to find 2 digits at the end of a string (0 matches)
16var_dump($match4);
17var_dump(preg_match_all('/(This is a ){2}(.*)\stest/', $string, $match5)); //tries to find "This is aThis is a [...] test" (0 matches)
18var_dump($match5);
19
20// Test not passing in a subpatterns array.
21var_dump(preg_match_all('/test/', $string));
22var_dump(preg_match_all('/this isn\'t in the string/', $string));
23var_dump(preg_match_all('/world/', $string));
24var_dump(preg_match_all('/[0-9]/', $string));
25?>
26--EXPECT--
27int(1)
28array(1) {
29  [0]=>
30  array(1) {
31    [0]=>
32    array(2) {
33      [0]=>
34      string(1) "3"
35      [1]=>
36      int(61)
37    }
38  }
39}
40int(2)
41array(2) {
42  [0]=>
43  array(2) {
44    [0]=>
45    string(15) "This is a test."
46    [1]=>
47    string(5) " test"
48  }
49  [1]=>
50  array(2) {
51    [0]=>
52    string(21) "This is another test."
53    [1]=>
54    string(11) "nother test"
55  }
56}
57int(1)
58array(2) {
59  [0]=>
60  array(1) {
61    [0]=>
62    string(21) ". \[4]. 34534 string."
63  }
64  [1]=>
65  array(1) {
66    [0]=>
67    string(17) "[4]. 34534 string"
68  }
69}
70int(0)
71array(1) {
72  [0]=>
73  array(0) {
74  }
75}
76int(0)
77array(3) {
78  [0]=>
79  array(0) {
80  }
81  [1]=>
82  array(0) {
83  }
84  [2]=>
85  array(0) {
86  }
87}
88int(2)
89int(0)
90int(1)
91int(6)
92