grep2.phpt 1.0 KB

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