3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highlight(string $search, string $number): string { $searchBegin = NULL; $searchIndex = 0; $search = str_replace([',', '.'], '', $search); foreach (str_split($number) as $numberIndex => $character) { if ($character == $search[$searchIndex]) { if (is_null($searchBegin)) { $searchBegin = $numberIndex; } $searchIndex++; if ($searchIndex == strlen($search)) { return substr($number, 0, $searchBegin) . '<span style="background: yellow">' . substr($number, $searchBegin, $numberIndex - $searchBegin + 1) . '</span>' . highlight($search, substr($number, $numberIndex + 1)); } } elseif (!in_array($character, [',', '.'])) { $searchBegin = NULL; $searchIndex = 0; } } return $number; } echo highlight('1234', '12,341,234.00') . PHP_EOL;

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.120.0110.01020.74
8.4.110.0130.00720.79
8.4.100.0120.00917.77
8.4.90.0120.00918.59
8.4.80.0140.00617.73
8.4.70.0110.01018.02
8.4.60.0050.00418.77
8.4.50.0070.01319.52
8.4.40.0120.00917.68
8.4.30.0130.00720.78
8.4.20.0050.01419.43
8.4.10.0060.00319.38
8.3.250.0130.00618.98
8.3.240.0120.00716.63
8.3.230.0120.00616.57
8.3.220.0100.00918.97
8.3.210.0050.00416.81
8.3.200.0030.00516.46
8.3.190.0130.00718.84
8.3.180.0030.00616.63
8.3.170.0040.01417.14
8.3.160.0090.00918.38
8.3.150.0040.01516.46
8.3.140.0100.00716.61
8.3.130.0060.00318.27
8.3.120.0040.00420.74
8.3.110.0230.01916.05
8.3.100.0460.00316.35
8.3.90.0470.00716.19
8.3.80.0500.00316.21
8.3.70.0400.00916.25
8.3.60.0430.00716.25
8.3.50.0350.00716.38
8.3.40.0300.01517.13
8.3.30.0100.00717.38
8.3.20.0150.00417.38
8.3.10.0240.01617.48
8.3.00.0130.00619.25
8.2.290.0120.00720.64
8.2.280.0040.00520.04
8.2.270.0170.00016.63
8.2.260.0060.00316.39
8.2.250.0040.00418.29
8.2.240.0060.00317.22
8.2.230.0280.00316.30
8.2.220.0310.00016.32
8.2.210.0190.01116.33
8.2.200.0310.00616.50
8.2.190.0360.00616.63
8.2.180.0320.00616.23
8.2.170.0370.00017.75
8.2.160.0310.01017.38
8.2.150.0430.00317.25
8.2.140.0420.00817.38
8.2.130.0320.00417.38
8.2.120.0270.01017.50
8.2.110.0400.00317.48
8.2.100.0310.01517.13
8.2.90.0350.00717.49
8.2.80.0300.01317.25
8.2.70.0330.01017.13
8.2.60.0420.00317.37
8.2.50.0380.00717.25
8.2.40.0390.00317.47
8.2.30.0310.01017.38
8.2.20.0280.01417.25
8.2.10.0400.00717.38
8.2.00.0240.00317.60
8.1.330.0070.01022.04
8.1.320.0130.00816.14
8.1.310.0040.00416.89
8.1.300.0030.00617.88
8.1.290.0160.00815.88
8.1.280.0300.00815.73
8.1.270.0230.00317.09
8.1.260.0310.01217.23
8.1.250.0340.00017.12
8.1.240.0340.00317.23
8.1.230.0250.00617.13
8.1.220.0150.00417.25
8.1.210.0290.00617.00
8.1.200.0220.00017.11
8.1.190.0290.00017.13
8.1.180.0240.00317.13
8.1.170.0180.00017.22
8.1.160.0230.00017.22
8.1.150.0320.00017.22
8.1.140.0160.00417.13
8.1.130.0200.00416.98
8.1.120.0280.00317.34
8.1.110.0210.00317.10
8.1.100.0200.00817.00
8.1.90.0190.01217.09
8.1.80.0220.00717.25
8.1.70.0240.00717.23
8.1.60.0280.00617.50
8.1.50.0390.00917.00
8.1.40.0360.01117.11
8.1.30.0250.00417.13
8.1.20.0230.00617.24
8.1.10.0190.00617.35
8.1.00.0130.00716.87

preferences:
30.44 ms | 403 KiB | 5 Q