3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'hello world'; $cnt = count(array_filter(str_split($str), function ($v) { return ord($v) % 3 == 0; })); echo 'total count- '.$cnt . PHP_EOL; $cnt = array_reduce(str_split($str), function ($c, $v) { return $c + (ord($v) % 3 == 0 ? 1 : 0); }, 0); echo 'total count- '.$cnt . PHP_EOL;

preferences:
28.4 ms | 402 KiB | 5 Q