3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convert(string $txt): string { do { $txt = preg_replace_callback_array( [ '~\[([bi])](.*?)\[/\1]~' => fn($m) => sprintf('<%1$s>%2$s</%1$s>', $m[1], $m[2]), '~\[img](.*?)\[/img]~' => 'foo', ], $txt, -1, $count ); } while ($count); return $txt; } function foo(array $m): string { return '<img src="' . $m[1] . '">'; } echo convert("text1 [img]path/src[/img] text2 [b]bold [i]nested string[/i][/b] [img]another/path/to/file[/img] [b]nice[/b] lingering end bbtag [/b] and [b]unclosed");

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.4.140.0110.01117.89
8.4.130.0160.00418.07
8.4.120.0130.00824.38
8.4.110.0130.00720.70
8.4.100.0120.00919.13
8.4.90.0130.00720.80
8.4.80.0140.00618.98
8.4.70.0080.00418.08
8.4.60.0130.00718.76
8.4.50.0140.00818.79
8.4.40.0090.00922.29
8.4.30.0110.00418.70
8.4.20.0150.00618.20
8.4.10.0060.00322.28
8.3.270.0130.00816.69
8.3.260.0070.00216.86
8.3.250.0110.00919.12
8.3.240.0120.00717.41
8.3.230.0110.01016.68
8.3.220.0110.00518.98
8.3.210.0080.01116.81
8.3.200.0050.00716.82
8.3.190.0040.00617.32
8.3.180.0090.00917.29
8.3.170.0090.00619.01
8.3.160.0030.01616.86
8.3.150.0120.00617.25
8.3.140.0040.00416.94
8.3.130.0030.00618.52
8.3.120.0090.00619.16
8.3.110.0060.00320.94
8.3.100.0030.00518.52
8.3.90.0030.00526.77
8.3.80.0000.01018.68
8.3.70.0100.00617.00
8.3.60.0040.01116.73
8.3.50.0150.00020.22
8.3.40.0090.01219.09
8.3.30.0070.00719.29
8.3.20.0080.00024.18
8.3.10.0080.00024.66
8.3.00.0000.00826.16
8.2.290.0120.00720.36
8.2.280.0070.00918.53
8.2.270.0110.00717.36
8.2.260.0070.01016.81
8.2.250.0100.01016.96
8.2.240.0060.00317.21
8.2.230.0050.00522.58
8.2.220.0030.00716.87
8.2.210.0040.00426.77
8.2.200.0030.00617.00
8.2.190.0080.00817.13
8.2.180.0160.00625.92
8.2.170.0100.01019.00
8.2.160.0100.00322.96
8.2.150.0040.00425.66
8.2.140.0030.00524.66
8.2.130.0070.00026.16
8.2.120.0030.00620.08
8.2.110.0050.00521.15
8.2.100.0060.00617.91
8.2.90.0030.00618.16
8.2.80.0060.00318.03
8.2.70.0030.00517.88
8.2.60.0040.00418.05
8.2.50.0030.00518.07
8.2.40.0000.00820.20
8.2.30.0000.00918.29
8.2.20.0040.00420.41
8.2.10.0060.00318.10
8.2.00.0070.00019.40
8.1.330.0100.01022.00
8.1.320.0120.00818.31
8.1.310.0050.00316.29
8.1.300.0090.00020.04
8.1.290.0060.00330.84
8.1.280.0130.00325.92
8.1.270.0090.00023.91
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0060.00320.79
8.1.230.0040.00722.16
8.1.220.0080.00017.76
8.1.210.0040.00418.88
8.1.200.0000.00917.48
8.1.190.0060.00317.60
8.1.180.0030.00618.10
8.1.170.0080.00018.71
8.1.160.0040.00419.00
8.1.150.0000.00718.88
8.1.140.0050.00217.57
8.1.130.0070.00019.02
8.1.120.0000.00717.57
8.1.110.0040.00417.69
8.1.100.0040.00417.64
8.1.90.0040.00417.66
8.1.80.0000.00717.64
8.1.70.0030.00317.73
8.1.60.0050.00317.68
8.1.50.0000.01017.72
8.1.40.0050.00517.67
8.1.30.0070.00417.80
8.1.20.0190.00517.62
8.1.10.0130.00317.72
8.1.00.0150.00017.63
8.0.300.0070.00020.03
8.0.290.0080.00016.88
8.0.280.0000.00718.52
8.0.270.0040.00418.18
8.0.260.0030.00318.39
8.0.250.0000.00717.12
8.0.240.0030.00317.00
8.0.230.0030.00317.15
8.0.220.0080.00017.13
8.0.210.0030.00317.03
8.0.200.0030.00317.15
8.0.190.0090.00017.00
8.0.180.0120.00017.08
8.0.170.0080.00517.09
8.0.160.0130.00417.05
8.0.150.0060.00916.93
8.0.140.0210.00017.00
8.0.130.0160.00416.98
8.0.120.0150.00416.95
8.0.110.0190.00017.00
8.0.100.0120.00916.96
8.0.90.0140.00517.12
8.0.80.0180.00616.97
8.0.70.0120.00817.09
8.0.60.0130.00816.94
8.0.50.0200.00016.95
8.0.30.0220.00017.05
8.0.20.0180.00417.11
8.0.10.0190.00417.22
7.4.330.0030.00315.55
7.4.320.0030.00316.81
7.4.300.0000.00716.77
7.4.290.0220.00016.90
7.4.280.0150.00616.67
7.4.270.0060.00316.73
7.4.260.0090.00916.85
7.4.250.0130.00916.88
7.4.240.0190.00416.68
7.4.230.0190.00416.71
7.4.220.0000.01516.83
7.4.210.0080.00716.84
7.4.200.0070.00716.68
7.4.190.0130.00516.71
7.4.180.0180.00016.74
7.4.160.0110.00816.77
7.4.150.0180.00016.75
7.4.140.0070.00916.78
7.4.130.0120.00216.63
7.4.120.0140.00416.63
7.4.110.0160.00316.73
7.4.100.0140.00416.80
7.4.90.0140.00416.58
7.4.80.0040.00816.72
7.4.70.0170.00016.76
7.4.60.0170.00016.62
7.4.50.0030.01316.62
7.4.40.0170.00016.61
7.4.30.0070.00416.53
7.4.20.0050.00516.45
7.4.10.0040.00816.66
7.4.00.0060.00616.61

preferences:
345.8 ms | 403 KiB | 5 Q