3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "Ham followed now ecstatic use speaking exercise may repeated. Himself he evident oh greatly my on inhabit general concern. It allowance prevailed enjoyment in it. Calling observe for who pressed raising his. Can connection instrument astonished unaffected his motionless preference. Announcing say boy precaution unaffected difficulty alteration him."; function countt($text, $word, $count = 0) { $found = ''; for ($i = 0; $i < strlen($word); $i++) { for ($j = 0; $j < strlen($text); $j++) { if ($word[$i] === $text[$j]) { $text = substr($text, 0, $j) . substr($text, $j + 1); $found .= $word[$i]; if ($found === $word) { $count++; return countt($text, $word, $count); } break; } } } return $count; } echo countt($text, 'potato');//6
Output for 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
6

preferences:
62.49 ms | 406 KiB | 5 Q