fork download
  1. <?php
  2. $string = "sdfsg, sdfg,sfgsdfgsf. sgdf.sd
  3. sdfgsdfg,sdfg.sdfgsdgsd.gsdfg,sdfg
  4. sd.fgsdfg,sdfg";
  5. $dotCount=0;
  6. $commaCount=0;
  7. for ($i=0; $i < strlen($string); $i++) {
  8. if ($string[$i] = ',') {
  9. $commaCount++;
  10. } else
  11. if ($string[$i] = '.') {
  12. $dotCount++;
  13. }
  14. }
  15. echo "Dot count=" . $dotCount . \PHP_EOL;
  16. echo "Comma count=" . $commaCount . \PHP_EOL;
  17. echo "Lines count=" . count($string) . \PHP_EOL;
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Dot count=0
Comma count=80
Lines count=1