3v4l.org

run code in 300+ PHP versions simultaneously
<?php function countLetters($matches) { return $matches[0] . '(' . strlen($matches[0]) . ')'; } $input = "Welcome to W3Schools.com!"; $pattern = '/[a-z0-9\.]+/i'; $limit = -1; $count = null; $flag = 0; $result = preg_replace_callback($pattern, 'countLetters', $input, $limit, $count, $flag); echo $result;
Output for 7.4.0 - 7.4.13, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Welcome(7) to(2) W3Schools.com(13)!
Output for 7.2.34, 7.3.0 - 7.3.33
Warning: preg_replace_callback() expects at most 5 parameters, 6 given in /in/6cAT6 on line 12

preferences:
55.94 ms | 407 KiB | 5 Q