bug66702.phpt 920 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. Bug #66702 (RegexIterator inverted result works as expected)
  3. --FILE--
  4. <?php
  5. /**
  6. * @author Joshua Thijssen <jthijssen+php@noxlogic.nl>
  7. */
  8. $it = new \ArrayIterator(array("foo", "bar", "baz"));
  9. $it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH);
  10. print_r(iterator_to_array($it2));
  11. $it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::INVERT_MATCH);
  12. print_r(iterator_to_array($it2));
  13. $it = new \ArrayIterator(array("foo" => 1, "bar" => 2, "baz" => 3));
  14. $it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY);
  15. print_r(iterator_to_array($it2));
  16. $it2 = new \RegexIterator($it, "/^ba/", \RegexIterator::MATCH, \RegexIterator::USE_KEY | \RegexIterator::INVERT_MATCH);
  17. print_r(iterator_to_array($it2));
  18. ?>
  19. --EXPECT--
  20. Array
  21. (
  22. [1] => bar
  23. [2] => baz
  24. )
  25. Array
  26. (
  27. [0] => foo
  28. )
  29. Array
  30. (
  31. [bar] => 2
  32. [baz] => 3
  33. )
  34. Array
  35. (
  36. [foo] => 1
  37. )