grep2.phpt 1.1 KB

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