PageRenderTime 40ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/preg_match_all().php

https://github.com/choi3961/php
PHP | 26 lines | 9 code | 5 blank | 12 comment | 1 complexity | c04903d33e226f0c5ad8890cf12b1c73 MD5 | raw file
  1. <?php
  2. $string = "/brown fox jumped [0-9]/";
  3. $paragraph = "The brown fox jumped 1 time over the fence. The green fox did not. Then the brown fox jumped 2 times over the fence";
  4. if (preg_match_all($string, $paragraph, &$matches)) {
  5. echo count($matches[0]) . " matches found";
  6. }else {
  7. echo "match NOT found";
  8. }
  9. ?>
  10. //echo "position:$pos<br>";
  11. /*******************************
  12. $string = "/'/";
  13. preg_match_all($string, $str,$matches);
  14. $num = count($matches[0]);
  15. //echo $num."<br>";
  16. if($num>1){
  17. echo "matches 2 above<br>";
  18. echo $str."<br>";
  19. }
  20. *********************************/