3v4l.org

run code in 300+ PHP versions simultaneously
<?php // array of authors, number of authors to take first function niceAuthorsPrint(array $authors, $takeCount){ $totalAuthors = count( $authors ); if($totalAuthors >= 3 && $takeCount >= $totalAuthors) { $takeCount = 2; } if($totalAuthors == 2 && $takeCount >= $totalAuthors) { $takeCount = 1; } $last = array_pop($authors); $tailCount = $totalAuthors - $takeCount; $first = array_slice($authors, 0, $takeCount); $othersLabel = $tailCount == 1 ? $last : $tailCount . ' others'; $string = implode( ", ", $first ); if($tailCount > 0){ $string .= " and " . $othersLabel; } return $string; } // take 3 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 3) ."\n"; // take 4 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 4) ."\n"; // take 5 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 5) ."\n"; // take original count, take first three as default echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 5) ."\n"; // take original count, take first three as default echo niceAuthorsPrint(array( 'user1', 'user2', 'user3'), 3) ."\n"; // take original count, take first three as default echo niceAuthorsPrint(array( 'user1', 'user2'), 2) ."\n";

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.0130.00817.68
8.4.130.0050.00517.83
8.4.120.0150.00520.81
8.4.110.0060.00322.48
8.4.100.0070.01017.92
8.4.90.0110.01018.82
8.4.80.0110.01020.66
8.4.70.0060.00317.70
8.4.60.0120.00918.62
8.4.50.0130.00718.76
8.4.40.0040.00417.86
8.4.30.0110.00017.78
8.4.20.0100.01020.69
8.4.10.0060.00319.75
8.3.270.0110.00916.49
8.3.260.0120.00716.82
8.3.250.0110.00818.82
8.3.240.0100.00916.67
8.3.230.0040.00316.43
8.3.220.0120.00617.18
8.3.210.0130.00518.35
8.3.200.0060.00316.68
8.3.190.0140.00516.93
8.3.180.0050.00416.74
8.3.170.0090.00917.31
8.3.160.0130.00616.54
8.3.150.0120.00617.37
8.3.140.0070.00716.48
8.3.130.0040.00416.85
8.3.120.0070.00320.77
8.3.110.0100.00020.94
8.3.100.0060.00924.06
8.3.90.0040.00726.77
8.3.80.0100.00017.97
8.3.70.0120.00316.63
8.3.60.0140.00718.27
8.3.50.0080.00818.19
8.3.40.0140.00018.84
8.3.30.0040.01118.60
8.3.20.0000.00818.66
8.3.10.0040.00423.66
8.3.00.0000.00721.73
8.2.290.0140.00620.54
8.2.280.0120.00518.40
8.2.270.0090.00918.87
8.2.260.0080.00020.62
8.2.250.0080.00018.41
8.2.240.0060.00317.11
8.2.230.0120.00622.58
8.2.220.0050.00337.54
8.2.210.0110.00726.77
8.2.200.0040.00418.16
8.2.190.0110.00416.58
8.2.180.0130.00416.50
8.2.170.0120.00922.96
8.2.160.0070.01019.41
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0080.00019.77
8.2.120.0110.00326.35
8.2.110.0080.00319.17
8.2.100.0040.00717.72
8.2.90.0060.00318.03
8.2.80.0000.00817.97
8.2.70.0000.00818.05
8.2.60.0000.00718.34
8.2.50.0050.00318.10
8.2.40.0000.00819.34
8.2.30.0050.00320.53
8.2.20.0040.00418.16
8.2.10.0040.00419.91
8.2.00.0050.00319.53
8.1.330.0080.01020.27
8.1.320.0120.00716.13
8.1.310.0030.00616.65
8.1.300.0030.00616.15
8.1.290.0090.00030.84
8.1.280.0090.00625.92
8.1.270.0060.00323.99
8.1.260.0090.00026.35
8.1.250.0050.00328.09
8.1.240.0070.00722.20
8.1.230.0050.00521.02
8.1.220.0040.00417.78
8.1.210.0000.00918.87
8.1.200.0060.00317.36
8.1.190.0000.00817.22
8.1.180.0040.00418.10
8.1.170.0040.00418.59
8.1.160.0000.00718.79
8.1.150.0000.00718.93
8.1.140.0000.00720.67
8.1.130.0050.00320.15
8.1.120.0030.00317.48
8.1.110.0050.00217.39
8.1.100.0000.00817.51
8.1.90.0040.00417.41
8.1.80.0050.00317.54
8.1.70.0030.00717.38
8.1.60.0000.00817.51
8.1.50.0040.00417.47
8.1.40.0070.00017.54
8.1.30.0040.00417.75
8.1.20.0080.00017.75
8.1.10.0040.00417.57
8.1.00.0050.00317.50
8.0.300.0040.00419.89
8.0.290.0090.00016.63
8.0.280.0070.00018.39
8.0.270.0000.00816.85
8.0.260.0000.00620.24
8.0.250.0070.00016.88
8.0.240.0060.00316.92
8.0.230.0030.00616.91
8.0.220.0000.00716.80
8.0.210.0040.00416.89
8.0.200.0000.00717.03
8.0.190.0040.00416.96
8.0.180.0040.00416.99
8.0.170.0060.00316.95
8.0.160.0000.00716.88
8.0.150.0040.00416.83
8.0.140.0060.00316.86
8.0.130.0060.00013.36
8.0.120.0050.00316.77
8.0.110.0040.00416.97
8.0.100.0000.00816.95
8.0.90.0070.00017.04
8.0.80.0060.01016.92
8.0.70.0050.00316.82
8.0.60.0000.00716.80
8.0.50.0080.00016.95
8.0.30.0060.01417.11
8.0.20.0070.01517.40
8.0.10.0000.00717.05
8.0.00.0150.00316.74
7.4.330.0050.00015.55
7.4.320.0030.00316.54
7.4.300.0000.00716.64
7.4.290.0030.00316.48
7.4.280.0070.00016.69
7.4.270.0060.00616.54
7.4.260.0040.00416.61
7.4.250.0000.00916.40
7.4.240.0000.00816.64
7.4.230.0050.00316.58
7.4.220.0050.00316.55
7.4.210.0050.01016.61
7.4.200.0070.00016.56
7.4.160.0120.00616.62
7.4.140.0100.01017.86
7.4.130.0030.01416.44
7.4.120.0110.00916.48
7.4.110.0100.00616.68
7.4.100.0110.00716.54
7.4.90.0140.00316.63
7.4.80.0140.00319.39
7.4.70.0070.01016.54
7.4.60.0110.01116.70
7.4.50.0080.00316.61
7.4.40.0100.00616.73
7.4.00.0070.00414.93
7.3.330.0000.00513.16
7.3.320.0000.00613.31
7.3.310.0040.00416.36
7.3.300.0000.00616.33
7.3.290.0000.00716.33
7.3.280.0110.00516.35
7.3.260.0110.00916.57
7.3.240.0130.00716.39
7.3.230.0000.01716.44
7.3.210.0070.01416.57
7.3.200.0120.00616.26
7.3.190.0130.01016.38
7.3.180.0120.00916.34
7.3.170.0030.01916.49
7.3.160.0080.00816.24
7.3.120.0070.01114.83
7.3.110.0060.00915.00
7.3.100.0090.00614.73
7.3.90.0030.00614.94
7.3.80.0000.01014.79
7.3.70.0070.00714.86
7.3.60.0030.00614.85
7.3.50.0040.00815.00
7.3.40.0100.00314.98
7.3.30.0060.01014.91
7.3.20.0090.00616.59
7.3.10.0110.00016.53
7.3.00.0100.00716.52
7.2.330.0110.00616.75
7.2.320.0160.00816.80
7.2.310.0150.00416.61
7.2.300.0070.01616.59
7.2.290.0110.00616.75
7.2.240.0090.00614.94
7.2.230.0040.01214.67
7.2.220.0070.00715.15
7.2.210.0000.01415.04
7.2.200.0090.00614.95
7.2.190.0000.01514.79
7.2.180.0070.00714.89
7.2.170.0130.00715.11
7.2.160.0000.01015.03
7.2.150.0160.00316.93
7.2.140.0060.00616.90
7.2.130.0070.00716.77
7.2.120.0070.00716.73
7.2.110.0100.00717.05
7.2.100.0030.01316.79
7.2.90.0370.00915.71
7.2.80.0170.00915.76
7.2.70.4500.00915.74
7.2.60.4160.01015.80
7.2.50.4050.01015.80
7.2.40.3040.01015.91
7.2.30.2380.00816.03
7.2.20.2600.01315.96
7.2.10.0550.00815.83
7.2.00.1990.00816.02
7.1.330.0100.00715.45
7.1.320.0030.01015.52
7.1.310.0040.01115.85
7.1.300.0040.00715.74
7.1.290.0000.01315.89
7.1.280.0100.00715.74
7.1.270.0070.01015.87
7.1.260.0130.00015.76
7.1.250.0070.00715.94
7.1.210.3700.01013.71
7.1.200.8720.00613.72
7.1.190.9440.01013.61
7.1.180.6180.01013.79
7.1.170.8080.00713.90
7.1.160.4670.00914.02
7.1.150.5030.01014.07
7.1.140.1200.01313.62
7.1.130.5220.00613.84
7.1.120.0210.00413.69
7.1.110.0460.00713.50
7.1.100.2990.00313.62
7.1.90.9140.00713.33
7.1.80.7000.00313.95
7.1.70.4110.01013.80
7.1.60.4580.00731.50
7.1.50.5650.00731.20
7.1.40.5080.01031.61
7.1.30.6230.00731.43
7.1.20.7570.01331.45
7.1.10.3060.00613.45
7.1.00.0120.00813.57

preferences:
174.22 ms | 403 KiB | 5 Q