3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Return an elipsis given a string and a number of words */ function elipsis ($text, $words = 30) { // Check if string has more than X words if (str_word_count($text) > $words) { // Extract first X words from string preg_match("/(?:[^\s,\.;\?\!]+(?:[\s,\.;\?\!]+|$)){0,$words}/", $text, $matches); $text = trim($matches[0]); // Let's check if it ends in a comma or a dot. if (substr($text, -1) == ',') { // If it's a comma, let's remove it and add a ellipsis $text = rtrim($text, ','); $text .= '...'; } else if (substr($text, -1) == '.') { // If it's a dot, let's remove it and add a ellipsis (optional) $text = rtrim($text, '.'); $text .= '...'; } else { // Doesn't end in dot or comma, just adding ellipsis here $text .= '...'; } } // Returns "ellipsed" text, or just the string, if it's less than X words wide. return $text; } $description = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quibusdam ut placeat consequuntur pariatur iure eum ducimus quasi perferendis, laborum obcaecati iusto ullam expedita excepturi debitis nisi deserunt fugiat velit assumenda. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Incidunt, blanditiis nostrum. Nostrum cumque non rerum ducimus voluptas officia tempore modi, nulla nisi illum, voluptates dolor sapiente ut iusto earum. Esse? Lorem ipsum dolor sit amet, consectetur adipisicing elit. A eligendi perspiciatis natus autem. Necessitatibus eligendi doloribus corporis quia, quas laboriosam. Beatae repellat dolor alias. Perferendis, distinctio, laudantium? Dolorum, veniam, amet!'; echo elipsis($description, 30);

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.5.10.0030.00421.41
8.5.00.0150.00720.31
8.4.150.0030.00014.05
8.4.140.0130.00817.89
8.4.130.0140.00717.86
8.4.120.0130.00720.55
8.4.110.0110.00822.36
8.4.100.0100.01117.74
8.4.90.0100.01118.19
8.4.80.0110.01017.95
8.4.70.0090.01119.75
8.4.60.0110.01018.70
8.4.50.0040.00420.10
8.4.40.0130.00719.81
8.4.30.0160.00720.52
8.4.20.0070.01322.52
8.4.10.0000.00819.55
8.3.280.0130.00718.73
8.3.270.0270.00716.95
8.3.260.0070.00516.54
8.3.250.0090.00418.93
8.3.240.0040.00416.82
8.3.230.0080.01316.82
8.3.220.0110.00816.65
8.3.210.0140.00516.92
8.3.200.0080.00316.88
8.3.190.0040.00617.21
8.3.180.0050.00418.42
8.3.170.0110.00720.93
8.3.160.0070.01118.74
8.3.150.0110.00719.01
8.3.140.0040.00818.76
8.3.130.0050.00318.48
8.3.120.0030.00720.71
8.3.110.0080.00017.15
8.3.100.0090.00016.71
8.3.90.0090.00926.77
8.3.80.0060.00318.43
8.3.70.0120.00917.00
8.3.60.0060.00918.55
8.3.50.0070.00518.52
8.3.40.0120.00319.05
8.3.30.0110.00418.76
8.3.20.0070.00023.53
8.3.10.0080.00021.89
8.3.00.0000.00720.64
8.2.290.0110.00820.54
8.2.280.0040.00522.67
8.2.270.0140.00417.23
8.2.260.0140.00418.64
8.2.250.0120.00618.72
8.2.240.0000.00817.27
8.2.230.0030.00520.94
8.2.220.0040.01124.06
8.2.210.0040.00426.77
8.2.200.0060.00318.31
8.2.190.0090.00918.68
8.2.180.0130.00625.92
8.2.170.0000.01522.96
8.2.160.0110.00421.37
8.2.150.0000.00724.18
8.2.140.0070.00024.66
8.2.130.0000.00826.16
8.2.120.0070.00021.17
8.2.110.0030.00619.35
8.2.100.0080.00417.84
8.2.90.0000.00817.88
8.2.80.0050.00519.02
8.2.70.0040.00417.75
8.2.60.0030.00617.75
8.2.50.0080.00018.03
8.2.40.0030.00618.16
8.2.30.0080.00019.38
8.2.20.0000.00818.06
8.2.10.0000.00819.12
8.2.00.0070.00019.36
8.1.330.0110.00816.55
8.1.320.0170.00516.08
8.1.310.0000.00918.68
8.1.300.0150.00418.40
8.1.290.0060.00330.84
8.1.280.0090.00625.92
8.1.270.0040.00424.66
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0050.00821.98
8.1.230.0040.00722.73
8.1.220.0000.00817.79
8.1.210.0000.00818.77
8.1.200.0000.00817.35
8.1.190.0080.00017.22
8.1.180.0030.00518.10
8.1.170.0030.00617.62
8.1.160.0090.00018.98
8.1.150.0040.00419.05
8.1.140.0050.00218.83
8.1.130.0030.00720.17
8.1.120.0000.00717.64
8.1.110.0050.00217.60
8.1.100.0040.00417.51
8.1.90.0040.00417.61
8.1.80.0040.00417.70
8.1.70.0000.00717.66
8.1.60.0000.00917.80
8.1.50.0040.00417.70
8.1.40.0000.00917.61
8.1.30.0000.00717.71
8.1.20.0040.00417.84
8.1.10.0060.00317.75
8.1.00.0030.00517.76
8.0.300.0070.00018.77
8.0.290.0000.00817.00
8.0.280.0030.00318.43
8.0.270.0030.00317.00
8.0.260.0040.00420.12
8.0.250.0030.00317.18
8.0.240.0000.00717.07
8.0.230.0070.00017.11
8.0.220.0030.00317.09
8.0.210.0060.00317.07
8.0.200.0030.00317.05
8.0.190.0000.00817.02
8.0.180.0000.00817.00
8.0.170.0000.00817.10
8.0.160.0040.00417.11
8.0.150.0040.00417.01
8.0.140.0000.00717.06
8.0.130.0000.00513.49
8.0.120.0000.00817.09
8.0.110.0040.00417.08
8.0.100.0000.00716.96
8.0.90.0090.00016.87
8.0.80.0120.00917.12
8.0.70.0030.00517.04
8.0.60.0040.00416.94
8.0.50.0040.00417.07
8.0.30.0080.01317.31
8.0.20.0060.01217.31
8.0.10.0050.00317.18
8.0.00.0120.00617.01
7.4.330.0000.00515.55
7.4.320.0000.00616.79
7.4.300.0060.00016.80
7.4.290.0040.00416.80
7.4.280.0040.00416.80
7.4.270.0000.00716.89
7.4.260.0030.00313.47
7.4.250.0040.00416.76
7.4.240.0060.00316.86
7.4.230.0030.00316.65
7.4.220.0030.00316.79
7.4.210.0060.01116.81
7.4.200.0040.00416.96
7.4.130.0040.01416.72
7.4.120.0070.01016.65
7.4.110.0070.01116.78
7.4.100.0040.01716.82
7.4.90.0140.00316.79
7.4.80.0110.01019.39
7.4.70.0100.00716.66
7.4.60.0110.00716.63
7.4.50.0090.00616.64
7.4.40.0090.00916.79
7.4.10.0040.01116.64
7.4.00.0070.01015.52
7.3.330.0040.00316.60
7.3.320.0000.00513.52
7.3.310.0030.00316.39
7.3.300.0050.00216.46
7.3.290.0030.00316.55
7.3.280.0110.00416.51
7.3.260.0130.00916.65
7.3.240.0120.00516.58
7.3.230.0140.00316.65
7.3.210.0100.00616.71
7.3.200.0160.00016.71
7.3.190.0030.01616.69
7.3.180.0110.00516.79
7.3.170.0030.01216.46
7.3.160.0040.01216.72
7.3.130.0130.01016.47
7.3.120.0090.01015.77
7.3.110.0070.01015.40
7.3.100.0120.00315.36
7.3.90.0080.00815.44
7.3.80.0120.00715.44
7.3.70.0050.01115.42
7.3.60.0070.00715.38
7.3.50.0090.00615.21
7.3.40.0120.00515.44
7.3.30.0080.00715.39
7.3.20.0080.00816.26
7.3.10.0080.00916.33
7.3.00.0100.00616.34
7.2.330.0090.00916.85
7.2.320.0100.00716.79
7.2.310.0100.01017.07
7.2.300.0090.01016.92
7.2.290.0110.00716.85
7.2.260.0120.00316.81
7.2.250.0100.00915.93
7.2.240.0100.00715.51
7.2.230.0090.00915.51
7.2.220.0060.01115.60
7.2.210.0060.01315.55
7.2.200.0090.00815.46
7.2.190.0050.00915.58
7.2.180.0080.00715.63
7.2.170.0080.00815.49
7.2.160.0080.00815.71
7.2.150.0160.00216.44
7.2.140.0070.01216.31
7.2.130.0070.01116.37
7.2.120.0090.01016.39
7.2.110.0070.00916.34
7.2.100.0080.00816.27
7.2.90.0100.01116.47
7.2.80.0080.01016.48
7.2.70.0050.01416.39
7.2.60.0060.01116.39
7.2.50.0080.01416.40
7.2.40.0120.00816.30
7.2.30.0100.01016.38
7.2.20.0100.01216.43
7.2.10.0090.01216.27
7.2.00.0070.01116.48
7.1.330.0100.00815.44
7.1.320.0160.01015.52
7.1.310.0050.01015.45
7.1.300.0080.00815.56
7.1.290.0070.00715.51
7.1.280.0060.00915.55
7.1.270.0070.00815.48
7.1.260.0070.01115.36
7.1.250.0070.01215.35
7.1.240.0100.00515.76
7.1.230.0070.00815.69
7.1.220.0130.00715.69
7.1.210.0110.00615.83
7.1.200.0100.00615.75
7.1.190.0080.00515.98
7.1.180.0120.00515.71
7.1.170.0060.00815.80
7.1.160.0090.01015.84
7.1.150.0080.00915.84
7.1.140.0050.01315.75
7.1.130.0090.01115.82
7.1.120.0100.00715.80
7.1.110.0060.00815.81
7.1.100.0100.00815.95
7.1.90.0060.01115.73
7.1.80.0100.00615.80
7.1.70.0100.01015.76
7.1.60.0060.01015.92
7.1.50.0080.00815.84
7.1.40.0100.00815.91
7.1.30.0050.01115.92
7.1.20.0080.00815.80
7.1.10.0110.00315.82
7.1.00.0110.00815.84
7.0.330.0100.00813.74
7.0.320.0140.00413.61
7.0.310.0110.01113.56
7.0.300.0090.01113.39
7.0.290.0100.01013.79
7.0.280.0060.01213.74
7.0.270.0040.01513.79
7.0.260.0060.01313.58
7.0.250.0100.01113.82
7.0.240.0000.01513.71
7.0.230.0130.00313.51
7.0.220.0090.01313.75
7.0.210.0110.01113.73
7.0.200.0110.00913.87
7.0.190.0030.01213.55
7.0.180.0190.00313.52
7.0.170.0060.01013.52
7.0.160.0000.01913.80
7.0.150.0080.00813.70
7.0.140.0090.01313.63
7.0.130.0100.00713.81
7.0.120.0100.01013.61
7.0.110.0030.01313.79
7.0.100.0110.00713.80
7.0.90.0070.01113.61
7.0.80.0100.01013.95
7.0.70.0110.00813.84
7.0.60.0170.00613.70
7.0.50.0090.00913.76
7.0.40.0100.00714.02
7.0.30.0130.00513.56
7.0.20.0120.01213.73
7.0.10.0120.00613.85
7.0.00.0070.01013.80
5.6.400.0090.00914.54
5.6.390.0090.01314.29
5.6.380.0090.00914.45
5.6.370.0140.01014.36
5.6.360.0060.01314.44
5.6.350.0110.00614.60
5.6.340.0060.01214.14
5.6.330.0150.00414.20
5.6.320.0080.01114.59
5.6.310.0150.00314.42
5.6.300.0130.00514.12
5.6.290.0110.00714.77
5.6.280.0050.01114.09
5.6.270.0090.01514.05
5.6.260.0090.00914.16
5.6.250.0030.02214.41
5.6.240.0030.01614.35
5.6.230.0130.00614.36
5.6.220.0090.01314.42
5.6.210.0130.01214.22
5.6.200.0000.01714.54
5.6.190.0140.00414.46
5.6.180.0060.01014.32
5.6.170.0100.01014.34
5.6.160.0100.01014.30
5.6.150.0160.00614.53
5.6.140.0060.01014.41
5.6.130.0170.00014.44
5.6.120.0030.01214.56
5.6.110.0160.00314.15
5.6.100.0070.01014.39
5.6.90.0130.00814.47
5.6.80.0130.00514.48
5.6.70.0070.01114.46
5.6.60.0060.00914.33
5.6.50.0070.01414.36
5.6.40.0160.00314.40
5.6.30.0040.01614.38
5.6.20.0050.01514.28
5.6.10.0160.00314.18
5.6.00.0040.01314.36
5.5.380.0110.00814.03
5.5.370.0130.00814.32
5.5.360.0140.01414.40
5.5.350.0150.00414.85
5.5.340.0120.00714.48
5.5.330.0100.00614.34
5.5.320.0120.00814.50
5.5.310.0110.00714.50
5.5.300.0070.00714.20
5.5.290.0110.00314.18
5.5.280.0160.00014.01
5.5.270.0170.00013.99
5.5.260.0050.01114.36
5.5.250.0160.00314.51
5.5.240.0110.00714.33
5.5.230.0080.00914.34
5.5.220.0090.00614.20
5.5.210.0130.00514.29
5.5.200.0000.02214.03
5.5.190.0100.01014.37
5.5.180.0110.00914.14
5.5.170.0040.01514.08
5.5.160.0090.00914.26
5.5.150.0120.01214.46
5.5.140.0170.00014.60
5.5.130.0130.01014.16
5.5.120.0080.00914.38
5.5.110.0120.00914.05
5.5.100.0100.00814.30
5.5.90.0130.00714.41
5.5.80.0150.00614.43
5.5.70.0190.00314.46
5.5.60.0080.01414.32
5.5.50.0190.00514.22
5.5.40.0100.01314.36
5.5.30.0180.00514.12
5.5.20.0090.00914.24
5.5.10.0170.00414.11
5.5.00.0150.00714.54
5.4.450.0040.01111.84
5.4.440.0170.00011.84
5.4.430.0070.00511.84
5.4.420.0090.00611.84
5.4.410.0030.01011.84
5.4.400.0100.00211.84
5.4.390.0030.00811.84
5.4.380.0060.00611.84
5.4.370.0170.00011.84
5.4.360.0060.01011.84
5.4.350.0100.00711.84
5.4.340.0100.00311.84
5.4.330.0090.00511.84
5.4.320.0090.00911.84
5.4.310.0170.00511.84
5.4.300.0060.00611.84
5.4.290.0060.01011.84
5.4.280.0040.00811.84
5.4.270.0100.00511.84
5.4.260.0100.00711.84
5.4.250.0140.00011.84
5.4.240.0080.00811.84
5.4.230.0170.00011.84
5.4.220.0100.00511.84
5.4.210.0070.01111.84
5.4.200.0180.00311.84
5.4.190.0070.01311.84
5.4.180.0140.00411.84
5.4.170.0050.01011.84
5.4.160.0110.00911.84
5.4.150.0130.00311.84
5.4.140.0140.00711.84
5.4.130.0190.00811.84
5.4.120.0110.00811.84
5.4.110.0130.00311.84
5.4.100.0200.00311.84
5.4.90.0140.00711.84
5.4.80.0130.00311.84
5.4.70.0090.01211.84
5.4.60.0180.00311.84
5.4.50.0170.00311.84
5.4.40.0110.00611.84
5.4.30.0080.00811.84
5.4.20.0180.00011.84
5.4.10.0100.00511.84
5.4.00.0130.00811.84
5.3.290.0150.00011.84
5.3.280.0090.00511.84
5.3.270.0070.00811.84
5.3.260.0110.00511.84
5.3.250.0070.00711.84
5.3.240.0080.00811.84
5.3.230.0170.00311.84
5.3.220.0070.00711.84
5.3.210.0110.00411.84
5.3.200.0100.00611.84
5.3.190.0170.00011.84
5.3.180.0090.01411.84
5.3.170.0100.00511.84
5.3.160.0140.00311.84
5.3.150.0150.00011.84
5.3.140.0100.00311.84
5.3.130.0110.00311.84
5.3.120.0160.00011.84
5.3.110.0100.00311.84
5.3.100.0170.00011.84
5.3.90.0120.00511.84
5.3.80.0110.00611.84
5.3.70.0070.00711.84
5.3.60.0100.00311.84
5.3.50.0150.00011.84
5.3.40.0120.00411.84
5.3.30.0050.00911.84
5.3.20.0100.00511.84
5.3.10.0030.01011.84
5.3.00.0130.00011.84
5.2.170.0100.00311.84
5.2.160.0000.01511.84
5.2.150.0070.00511.84
5.2.140.0040.00711.84
5.2.130.0150.00011.84
5.2.120.0070.00411.84
5.2.110.0000.01111.84
5.2.100.0070.00411.84
5.2.90.0110.00011.84
5.2.80.0110.00211.84
5.2.70.0080.00411.84
5.2.60.0000.01111.84
5.2.50.0070.00711.84
5.2.40.0080.00411.84
5.2.30.0100.00311.84
5.2.20.0040.00811.84
5.2.10.0080.00211.84
5.2.00.0070.00411.84
5.1.60.0080.00311.84
5.1.50.0060.00611.84
5.1.40.0120.00011.84
5.1.30.0030.00711.84
5.1.20.0100.00511.84
5.1.10.0080.00311.84
5.1.00.0120.00011.84
5.0.50.0050.00511.84
5.0.40.0040.00811.84
5.0.30.0060.00611.84
5.0.20.0050.00411.84
5.0.10.0090.00211.84
5.0.00.0080.00411.84
4.4.90.0050.00311.84
4.4.80.0000.00711.84
4.4.70.0000.00911.84
4.4.60.0070.00011.84
4.4.50.0000.00711.84
4.4.40.0060.00311.84
4.4.30.0070.00211.84
4.4.20.0080.00411.84
4.4.10.0040.00511.84
4.4.00.0040.00411.84
4.3.110.0060.00311.84
4.3.100.0050.00211.84
4.3.90.0060.00311.84
4.3.80.0070.00211.84
4.3.70.0050.00511.84
4.3.60.0060.00211.84
4.3.50.0100.00011.84
4.3.40.0070.00311.84
4.3.30.0060.00411.84
4.3.20.0060.00411.84
4.3.10.0040.00411.84
4.3.00.0070.00311.84

preferences:
183.78 ms | 403 KiB | 5 Q