3v4l.org

run code in 300+ PHP versions simultaneously
<?php // old and new strings $old = "Foo \r\nFoo\r\nBar\r\nQux"; $new = "Foo\nBar\nBaz"; // convert all line endings to the same type $old = str_replace(["\r\n", "\r"], "\n", $old); $new = str_replace(["\r\n", "\r"], "\n", $new); // seperate into lines $old_lines = explode("\n", $old); $new_lines = explode("\n", $new); // optional: remove whitespace so spaces don't trigger falsely array_walk($old_lines, function(&$value) { $value = rtrim($value); }); array_walk($new_lines, function(&$value) { $value = rtrim($value); }); // figure out which one is longer if (count($old_lines) >= count($new_lines)) { $primary = $old_lines; $secondary = $new_lines; } else { $primary = $new_lines; $secondary = $old_lines; } // compare line by line $results = []; foreach ($primary as $key => $value) { if (key_exists($key, $secondary)) { if ($primary[$key] == $secondary[$key]) { $results[] = "MATCH"; } else { $results[] = "DIFFERENT"; } } else { $results[] = "MISSING"; } } var_dump($old_lines); var_dump($new_lines); var_dump($results);

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.60.0160.00618.55
8.3.50.0110.00416.13
8.3.40.0120.00918.68
8.3.30.0110.00718.75
8.3.20.0040.00418.87
8.3.10.0040.00421.76
8.3.00.0000.00819.69
8.2.180.0040.01116.50
8.2.170.0090.00622.96
8.2.160.0140.00019.40
8.2.150.0060.00324.18
8.2.140.0070.00024.66
8.2.130.0050.00222.27
8.2.120.0030.01326.35
8.2.110.0030.00722.14
8.2.100.0080.00317.96
8.2.90.0040.00418.34
8.2.80.0050.00318.03
8.2.70.0030.00617.93
8.2.60.0000.00817.93
8.2.50.0030.00618.10
8.2.40.0040.00420.46
8.2.30.0000.00819.41
8.2.20.0000.00818.19
8.2.10.0040.00418.06
8.2.00.0070.00018.14
8.1.280.0130.00725.92
8.1.270.0050.00324.01
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0050.00522.19
8.1.230.0040.00721.01
8.1.220.0040.00417.79
8.1.210.0030.00518.77
8.1.200.0030.00617.35
8.1.190.0030.00517.22
8.1.180.0040.00418.10
8.1.170.0030.00618.44
8.1.160.0000.00718.89
8.1.150.0090.00020.06
8.1.140.0040.00419.49
8.1.130.0030.00518.84
8.1.120.0040.00417.45
8.1.110.0050.00317.42
8.1.100.0000.00717.34
8.1.90.0050.00317.40
8.1.80.0050.00217.49
8.1.70.0080.00017.52
8.1.60.0040.00417.56
8.1.50.0030.00617.46
8.1.40.0000.00917.60
8.1.30.0000.00817.68
8.1.20.0000.00817.57
8.1.10.0050.00317.63
8.1.00.0050.00217.41
8.0.300.0070.00019.69
8.0.290.0040.00416.75
8.0.280.0030.00618.46
8.0.270.0000.00717.40
8.0.260.0070.00019.01
8.0.250.0000.00716.87
8.0.240.0050.00316.89
8.0.230.0030.00316.91
8.0.220.0000.00716.93
8.0.210.0000.00716.96
8.0.200.0080.00016.93
8.0.190.0000.00816.86
8.0.180.0040.00416.89
8.0.170.0050.00216.96
8.0.160.0040.00416.98
8.0.150.0050.00316.95
8.0.140.0040.00416.84
8.0.130.0000.00613.27
8.0.120.0000.00816.77
8.0.110.0040.00416.75
8.0.100.0040.00416.88
8.0.90.0040.00416.79
8.0.80.0090.00816.89
8.0.70.0040.00417.02
8.0.60.0060.00316.80
8.0.50.0080.00016.84
8.0.30.0110.01017.12
8.0.20.0100.01317.40
8.0.10.0040.00417.01
8.0.00.0090.00916.86
7.4.330.0000.00615.55
7.4.320.0030.00316.48
7.4.300.0000.00616.51
7.4.290.0030.00316.51
7.4.280.0000.00716.40
7.4.270.0070.00016.57
7.4.260.0050.00216.61
7.4.250.0030.00516.48
7.4.240.0080.00016.67
7.4.230.0000.00716.35
7.4.220.0150.00616.64
7.4.210.0060.00816.62
7.4.200.0000.00716.41
7.4.160.0140.00216.58
7.4.150.0120.00617.40
7.4.140.0100.01117.86
7.4.130.0100.01016.46
7.4.120.0130.01316.54
7.4.110.0130.01016.46
7.4.100.0090.01316.45
7.4.90.0090.01116.41
7.4.80.0100.00917.96
7.4.70.0100.00716.46
7.4.60.0060.01116.50
7.4.50.0090.00716.53
7.4.40.0100.01216.48
7.4.30.0120.01016.50
7.4.20.0120.00616.41
7.4.10.0050.01115.75
7.4.00.0090.00815.40
7.3.330.0040.00413.20
7.3.320.0030.00313.19
7.3.310.0070.00016.37
7.3.300.0060.00016.30
7.3.290.0000.00716.33
7.3.280.0070.01016.36
7.3.270.0100.00717.40
7.3.260.0120.01016.49
7.3.250.0150.00516.43
7.3.240.0150.00716.44
7.3.230.0120.00916.50
7.3.220.0040.01516.35
7.3.210.0110.00716.39
7.3.200.0050.01116.41
7.3.190.0110.00516.36
7.3.180.0060.01116.49
7.3.170.0110.00616.57
7.3.160.0110.00816.46
7.3.150.0090.01316.39
7.3.140.0110.01116.37
7.3.130.0080.00815.66
7.3.120.0110.00615.44
7.3.110.0050.01115.47
7.3.100.0140.00315.53
7.3.90.0080.01415.43
7.3.80.0070.00915.43
7.3.70.0050.01215.58
7.3.60.0060.01215.58
7.3.50.0060.01415.46
7.3.40.0030.01315.33
7.3.30.0050.01015.34
7.3.20.0100.00615.69
7.3.10.0060.00915.87
7.3.00.0080.00915.84
7.2.340.0190.00816.50
7.2.330.0130.00716.55
7.2.320.0070.01016.77
7.2.310.0080.00916.69
7.2.300.0120.00816.48
7.2.290.0090.01216.64
7.2.280.0060.01816.86
7.2.270.0120.00616.66
7.2.260.0140.00315.75
7.2.250.0060.01115.88
7.2.240.0110.00615.61
7.2.230.0150.00315.79
7.2.220.0090.00715.77
7.2.210.0100.00615.95
7.2.200.0110.00915.71
7.2.190.0080.00815.48
7.2.180.0050.01415.63
7.2.170.0090.00915.57
7.2.160.0070.01015.60
7.2.150.0050.01615.86
7.2.140.0100.00715.88
7.2.130.0100.00816.01
7.2.120.0090.00916.11
7.2.110.0090.00715.81
7.2.100.0080.01016.13
7.2.90.0130.00615.95
7.2.80.0110.00616.11
7.2.70.0090.00916.10
7.2.60.0120.00716.07
7.2.50.0070.01016.11
7.2.40.0080.01016.12
7.2.30.0100.01116.15
7.2.20.0090.01015.87
7.2.10.0070.00916.05
7.2.00.0120.00716.19
7.1.330.0200.00614.93
7.1.320.0260.00714.90
7.1.310.0190.00914.99
7.1.300.0180.00914.81
7.1.290.0180.00914.63
7.1.280.0270.00314.71
7.1.270.0190.00614.68
7.1.260.0230.00514.74
7.1.250.0150.00714.90
7.1.240.0270.00314.72
7.1.230.0200.00714.79
7.1.220.0210.00714.82
7.1.210.0460.00914.80
7.1.200.0120.00815.10
7.1.190.0120.02014.76
7.1.180.0200.00814.70
7.1.170.0140.01414.72
7.1.160.0170.01014.79
7.1.150.0150.01214.82
7.1.140.0170.00414.71
7.1.130.0100.00814.55
7.1.120.0070.01314.67
7.1.110.0120.00814.67
7.1.100.0150.00514.89
7.1.90.0200.00614.69
7.1.80.0160.00414.68
7.1.70.0110.00715.56
7.1.60.0130.00615.52
7.1.50.0210.00820.85
7.1.40.0200.01220.71
7.1.30.0270.00620.65
7.1.20.0180.00820.64
7.1.10.0150.00714.72
7.1.00.0170.00714.65
7.0.330.0190.00614.45
7.0.320.0150.01014.48
7.0.310.0150.01014.42
7.0.300.0210.00314.36
7.0.290.0170.00814.37
7.0.280.0160.00714.29
7.0.270.0160.00914.38
7.0.260.0160.00514.26
7.0.250.0140.00814.36
7.0.240.0070.01114.31
7.0.230.0080.01114.42
7.0.220.0150.00514.19
7.0.210.0140.00514.51
7.0.200.0200.00515.19
7.0.190.0200.00214.48
7.0.180.0160.01014.38
7.0.170.0130.01114.46
7.0.160.0100.01314.45
7.0.150.0120.01114.43
7.0.140.0130.00914.18
7.0.130.0180.00914.45
7.0.120.0160.00514.51
7.0.110.0150.00914.36
7.0.100.0080.01414.37
7.0.90.0130.00714.34
7.0.80.0130.01214.38
7.0.70.0360.00614.40
7.0.60.0110.01014.29
7.0.50.0140.00814.42
7.0.40.0110.00814.34
7.0.30.0160.00414.49
7.0.20.0150.00814.40
7.0.10.0150.00814.17
7.0.00.0150.00614.28
5.6.400.0170.00915.24
5.6.390.0130.01315.14
5.6.380.0230.01115.39
5.6.370.0240.00415.29
5.6.360.0080.01815.11
5.6.350.0140.01215.16
5.6.340.0120.01115.20
5.6.330.0120.00715.24
5.6.320.0080.01415.02
5.6.310.0090.01215.23
5.6.300.0160.00815.12
5.6.290.0150.01115.14
5.6.280.0110.01115.38
5.6.270.0130.00815.14
5.6.260.0110.01515.06
5.6.250.0190.00514.92
5.6.240.0130.00815.12
5.6.230.0130.01115.16
5.6.220.0120.00915.09
5.6.210.0140.01015.24
5.6.200.0090.01015.02
5.6.190.0110.00814.90
5.6.180.0140.01215.18
5.6.170.0160.00915.09
5.6.160.0140.01115.07
5.6.150.0150.01015.10
5.6.140.0160.01115.33
5.6.130.0160.01015.10
5.6.120.0130.01315.10
5.6.110.0180.00614.95
5.6.100.0140.01014.75
5.6.90.0150.01114.99
5.6.80.0120.01314.88
5.6.70.0130.01014.88
5.6.60.0160.00715.03
5.6.50.0140.01115.08
5.6.40.0170.00714.95
5.6.30.0170.00514.93
5.6.20.0180.00614.82
5.6.10.0150.01014.96
5.6.00.0120.00915.02

preferences:
60.2 ms | 401 KiB | 5 Q