xref: /PHP-5.3/ext/pcre/tests/grep2.phpt (revision 6fb763c4)
1--TEST--
2preg_grep() 2nd test
3--FILE--
4<?php
5
6var_dump(preg_grep(1,array(),3,4));
7var_dump(preg_grep(1, 2));
8var_dump(preg_grep('/+/', array()));
9
10$array = array(5=>'a', 'x' => '1', 'xyz'=>'q6', 'h20');
11
12var_dump(preg_grep('@^[a-z]+@', $array));
13var_dump(preg_grep('@^[a-z]+@', $array, PREG_GREP_INVERT));
14
15ini_set('pcre.recursion_limit', 1);
16var_dump(preg_last_error() == PREG_NO_ERROR);
17var_dump(preg_grep('@^[a-z]+@', $array));
18var_dump(preg_last_error() == PREG_RECURSION_LIMIT_ERROR);
19
20?>
21--EXPECTF--
22Warning: preg_grep() expects at most 3 parameters, 4 given in %sgrep2.php on line 3
23NULL
24
25Warning: preg_grep() expects parameter 2 to be array, integer given in %sgrep2.php on line 4
26NULL
27
28Warning: preg_grep(): Compilation failed: nothing to repeat at offset 0 in %sgrep2.php on line 5
29bool(false)
30array(3) {
31  [5]=>
32  string(1) "a"
33  ["xyz"]=>
34  string(2) "q6"
35  [6]=>
36  string(3) "h20"
37}
38array(1) {
39  ["x"]=>
40  string(1) "1"
41}
42bool(true)
43array(0) {
44}
45bool(true)
46