preg_match_basic_002.phpt 493 B

1234567891011121314151617181920212223
  1. --TEST--
  2. preg_match() single line match with multi-line input
  3. --FILE--
  4. <?php
  5. /* Prototype : int preg_match ( string $pattern , string $subject [, array &$matches [, int $flags [, int $offset ]]] )
  6. * Description: Perform a regular expression match
  7. * Source code: ext/pcre/php_pcre.c
  8. */
  9. $string = "My\nName\nIs\nStrange";
  10. preg_match("/M(.*)/", $string, $matches);
  11. var_dump($matches);
  12. ?>
  13. ===Done===
  14. --EXPECTF--
  15. array(2) {
  16. [0]=>
  17. string(2) "My"
  18. [1]=>
  19. string(1) "y"
  20. }
  21. ===Done===