3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "This is a " . str_repeat("test", 2) . "!\n" . str_repeat("hello", 3) . " and Bye!\n" . "When I sleep, the thought bubble says " . str_repeat("zz", 3) . "."; echo preg_replace_callback( '~\b(\w+?)\1+\b~', function($m) { return "[{$m[1]}](" . (strlen($m[0]) / strlen($m[1])) . ")"; }, $string );
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
This is a [test](2)! [hello](3) and Bye! When I sleep, the thought bubble says [z](6).

preferences:
154 ms | 407 KiB | 5 Q