fork download
  1. <?php
  2.  
  3. $text = 'gcdgcdgcd';
  4. $match = 'gcdgcd';
  5.  
  6. $ans = 0;
  7.  
  8. for ($i = 0; $i + strlen($match) <= strlen($text); $i++) {
  9. if (substr($text, $i, strlen($match)) === $match) {
  10. $ans += 1;
  11. }
  12. }
  13.  
  14. echo $ans;
Success #stdin #stdout 0.02s 24548KB
stdin
Standard input is empty
stdout
2