<?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); ?>
You have javascript disabled. You will not be able to edit any code.