3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = ''; for( $i = 0; $i <= 100; $i++ ) { $str .= str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'); } $start = microtime(true); for( $i = 0; $i<800000; $i++ ) { substr_count( 'foobar', $str ); } echo "count: " . (microtime(true)-$start) . PHP_EOL; $start = microtime(true); for( $i = 0; $i<800000; $i++ ) { preg_match_all( '/foobar/', $str ); } echo "rcount: " . (microtime(true)-$start) . PHP_EOL;

preferences:
29.38 ms | 402 KiB | 5 Q