3v4l.org

run code in 300+ PHP versions simultaneously
<?php function findFirstOccurance($str){ $arr = explode(' ',$str); $counter = 0; foreach($arr as $value){ $counter=$counter+strlen($value); #echo $counter.PHP_EOL; if($value > 10000){ return $counter - 1; } } } $str = "20 plus 1000 is not 20000."; echo findFirstOccurance($str); ?>

preferences:
173.32 ms | 404 KiB | 5 Q