3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = 'hello w1 w2 w12 new1 new12 new2'; $map = [ 'w1' => 'new1', 'w2' => 'new2', 'new1' => 'w1', 'new2' => 'w2', ]; $subpattern = implode('|', array_map('preg_quote', array_keys($map))); echo preg_replace_callback( '#\b(?:' . $subpattern . ')\b#u', fn($m) => $map[$m[0]] ?? $m[0], $string );

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.70.0040.01818.68
8.3.60.0040.01117.00
8.3.50.0120.00417.13
8.3.40.0070.00723.64
8.3.30.0150.00622.96
8.3.20.0000.01823.49
8.3.10.0120.00623.71
8.3.00.0110.00722.96
8.2.190.0110.00416.88
8.2.180.0070.01316.88
8.2.170.0000.01422.96
8.2.160.0120.00822.96
8.2.150.0120.00622.96
8.2.140.0110.00722.96
8.2.130.0090.00922.96
8.2.120.0070.01022.96
8.2.110.0040.01622.96
8.2.100.0120.00822.96
8.2.90.0210.00022.96
8.2.80.0160.00322.96
8.2.70.0150.00422.96
8.2.60.0100.01022.96
8.2.50.0110.01122.96
8.2.40.0130.00722.96
8.2.30.0070.01422.96
8.2.20.0100.00622.96
8.2.10.0100.00622.96
8.2.00.0100.00622.96
8.1.280.0120.00325.92
8.1.270.0100.01023.79
8.1.260.0130.00723.73
8.1.250.0130.00723.79
8.1.240.0130.01022.96
8.1.230.0090.00622.96
8.1.220.0040.01122.96
8.1.210.0130.01022.96
8.1.200.0140.00722.96
8.1.190.0130.00722.96
8.1.180.0070.01322.96
8.1.170.0130.00722.96
8.1.160.0170.00322.96
8.1.150.0060.00922.96
8.1.140.0160.00622.96
8.1.130.0130.00922.96
8.1.120.0080.00822.96
8.1.110.0120.00322.96
8.1.100.0100.00722.96
8.1.90.0070.01022.96
8.1.80.0030.01322.96
8.1.70.0030.01322.96
8.1.60.0150.00622.96
8.1.50.0090.00622.96
8.1.40.0110.00722.96
8.1.30.0110.00722.96
8.1.20.0140.00322.96
8.1.10.0060.01222.96
8.1.00.0060.00922.96

preferences:
18.57 ms | 401 KiB | 5 Q