xref: /PHP-7.3/ext/pcre/tests/grep2.phpt (revision e68fd40e)
1--TEST--
2preg_grep() 2nd test
3--SKIPIF--
4<?php if (!PCRE_JIT_SUPPORT) die("skip no pcre jit support"); ?>
5--INI--
6pcre.jit=1
7--FILE--
8<?php
9
10var_dump(preg_grep(1,array(),3,4));
11var_dump(preg_grep(1, 2));
12var_dump(preg_grep('/+/', array()));
13
14$array = array(5=>'a', 'x' => '1', 'xyz'=>'q6', 'h20');
15
16var_dump(preg_grep('@^[a-z]+@', $array));
17var_dump(preg_grep('@^[a-z]+@', $array, PREG_GREP_INVERT));
18
19ini_set('pcre.recursion_limit', 1);
20var_dump(preg_last_error() == PREG_NO_ERROR);
21var_dump(preg_grep('@^[a-z]+@', $array));
22var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
23
24?>
25--EXPECTF--
26Warning: preg_grep() expects at most 3 parameters, 4 given in %sgrep2.php on line 3
27NULL
28
29Warning: preg_grep() expects parameter 2 to be array, int given in %sgrep2.php on line 4
30NULL
31
32Warning: preg_grep(): Compilation failed: quantifier does not follow a repeatable item at offset 0 in %sgrep2.php on line 5
33bool(false)
34array(3) {
35  [5]=>
36  string(1) "a"
37  ["xyz"]=>
38  string(2) "q6"
39  [6]=>
40  string(3) "h20"
41}
42array(1) {
43  ["x"]=>
44  string(1) "1"
45}
46bool(true)
47array(3) {
48  [5]=>
49  string(1) "a"
50  ["xyz"]=>
51  string(2) "q6"
52  [6]=>
53  string(3) "h20"
54}
55bool(false)
56