3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "[ABC] This & Text"; Echo make_post_type($string); function make_post_type($string) { $needle = array('-', ' '); $arr = explode(" ", $string); foreach($arr as &$a){ if($a[0] != "[" && $a[-1] != "]"){ $a = preg_replace("/[^a-zA-Z0-9_\s]/", "", strtolower($a)); // Remove special characters }else{ $a = substr($a, 1,-1); } } $string = preg_replace('!\s+!', ' ', implode(" ", $arr)); // Now remove extra spaces return str_replace($needle, '_', $string); }

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.0090.00916.89
8.5.00.0120.01020.19
8.4.150.0020.00014.05
8.4.140.0120.00917.78
8.4.130.0130.00917.91
8.4.120.0130.00820.52
8.4.110.0170.00418.84
8.4.100.0140.00618.68
8.4.90.0050.00619.08
8.4.80.0060.00618.76
8.4.70.0110.01018.08
8.4.60.0070.00418.64
8.4.50.0050.00318.84
8.4.40.0030.01719.81
8.4.30.0140.00319.63
8.4.20.0210.00020.38
8.4.10.0090.00017.82
8.3.280.0090.01018.63
8.3.270.0090.01016.77
8.3.260.0120.00716.84
8.3.250.0040.00418.70
8.3.240.0140.00516.61
8.3.230.0110.00916.76
8.3.220.0100.00819.11
8.3.210.0100.00818.66
8.3.200.0070.00216.64
8.3.190.0100.00517.03
8.3.180.0070.00917.05
8.3.170.0090.00920.59
8.3.160.0150.00616.94
8.3.150.0150.00316.85
8.3.140.0080.01216.67
8.3.130.0100.01018.66
8.3.120.0070.01120.91
8.3.110.0100.00716.88
8.3.100.0090.00024.06
8.3.90.0060.00326.77
8.3.80.0090.00016.63
8.3.70.0120.00916.75
8.3.60.0030.01218.55
8.3.50.0090.00918.48
8.3.40.0100.01018.82
8.3.30.0090.00618.59
8.3.20.0000.00818.95
8.3.10.0040.00423.65
8.3.00.0040.00422.51
8.2.290.0110.00520.36
8.2.280.0020.00518.74
8.2.270.0150.00417.39
8.2.260.0030.00516.63
8.2.250.0070.00716.61
8.2.240.0000.00918.96
8.2.230.0030.00620.94
8.2.220.0060.00337.54
8.2.210.0000.00726.77
8.2.200.0060.00316.88
8.2.190.0070.00716.88
8.2.180.0070.00718.79
8.2.170.0120.00322.96
8.2.160.0100.00319.51
8.2.150.0030.00524.18
8.2.140.0030.00524.66
8.2.130.0040.00417.97
8.2.120.0040.00426.35
8.2.110.0070.00419.27
8.2.100.0060.00618.03
8.2.90.0000.00818.16
8.2.80.0080.00017.97
8.2.70.0000.00817.93
8.2.60.0050.00318.16
8.2.50.0060.00318.10
8.2.40.0070.00019.42
8.2.30.0020.00519.32
8.2.20.0050.00318.18
8.2.10.0040.00419.81
8.2.00.0060.00317.72
8.1.330.0120.00622.32
8.1.320.0120.00816.54
8.1.310.0150.00318.68
8.1.300.0120.00316.18
8.1.290.0090.00330.84
8.1.280.0040.01125.92
8.1.270.0090.00019.00
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0040.00419.34
8.1.230.0090.00322.65
8.1.220.0050.00317.78
8.1.210.0090.00019.04
8.1.200.0040.00717.35
8.1.190.0000.00817.53
8.1.180.0040.00418.10
8.1.170.0060.00318.91
8.1.160.0040.00418.91
8.1.150.0040.00418.82
8.1.140.0050.00223.88
8.1.130.0080.00020.06
8.1.120.0040.00417.67
8.1.110.0000.00817.50
8.1.100.0040.00417.50
8.1.90.0100.00017.48
8.1.80.0040.00417.59
8.1.70.0080.00017.48
8.1.60.0060.00317.71
8.1.50.0000.00817.57
8.1.40.0020.00517.54
8.1.30.0000.00817.82
8.1.20.0040.00417.64
8.1.10.0000.00817.75
8.1.00.0020.00517.62
8.0.300.0040.00419.84
8.0.290.0040.00416.75
8.0.280.0030.00518.46
8.0.270.0030.00317.27
8.0.260.0000.00620.11
8.0.250.0040.00417.08
8.0.240.0030.00317.08
8.0.230.0070.00017.12
8.0.220.0030.00716.92
8.0.210.0040.00417.02
8.0.200.0000.00717.07
8.0.190.0080.00017.13
8.0.180.0040.00417.06
8.0.170.0040.00417.06
8.0.160.0000.00716.95
8.0.150.0050.00316.92
8.0.140.0080.00016.84
8.0.130.0000.00613.41
8.0.120.0000.00716.91
8.0.110.0040.00417.07
8.0.100.0000.00717.07
8.0.90.0000.00716.98
8.0.80.0040.01117.05
8.0.70.0000.00817.14
8.0.60.0030.00516.86
8.0.50.0040.00417.03
8.0.30.0120.00917.26
8.0.20.0130.00817.41
8.0.10.0040.00417.05
8.0.00.0130.01017.09
7.4.330.0060.00015.55
7.4.320.0040.00416.63
7.4.300.0060.00016.62
7.4.290.0000.00716.60
7.4.280.0040.00416.69
7.4.270.0000.00816.68
7.4.260.0050.00216.70
7.4.250.0040.00416.66
7.4.240.0000.00816.81
7.4.230.0030.00316.75
7.4.220.0040.00416.86
7.4.210.0080.00816.72
7.4.200.0000.00716.59
7.4.160.0100.00716.77
7.4.140.0110.00817.86
7.4.130.0090.01016.78
7.4.120.0100.00816.76
7.4.110.0060.01216.71
7.4.100.0110.00716.82
7.4.90.0060.01216.66
7.4.80.0090.00919.39
7.4.70.0090.01316.59
7.4.60.0140.00416.82
7.4.50.0110.00716.46
7.4.40.0060.01716.61
7.4.10.0070.01114.98
7.4.00.0070.01215.12
7.3.330.0000.00613.32
7.3.320.0050.00013.36
7.3.310.0030.00516.48
7.3.300.0070.00016.47
7.3.290.0070.00016.33
7.3.280.0090.00616.39
7.3.260.0120.00916.56
7.3.240.0090.00916.61
7.3.230.0160.00016.86
7.3.210.0070.01016.84
7.3.200.0060.01116.86
7.3.190.0090.00616.71
7.3.180.0130.00316.71
7.3.170.0040.01516.77
7.3.160.0130.00316.89
7.3.130.0000.01815.05
7.3.120.0030.01414.91
7.3.110.0050.00515.19
7.3.100.0080.00815.09
7.3.90.0060.00914.82
7.3.80.0070.00715.22
7.3.70.0030.01315.11
7.3.60.0090.00315.04
7.3.50.0100.00015.07
7.3.40.0060.00314.73
7.3.30.0000.01515.13
7.3.20.0060.00616.98
7.3.10.0030.00616.98
7.3.00.0120.00316.82
7.2.330.0180.00716.98
7.2.320.0100.01016.89
7.2.310.0030.01717.02
7.2.300.0060.00916.85
7.2.290.0060.01016.99
7.2.260.0100.01015.28
7.2.250.0060.00915.14
7.2.240.0030.01315.03
7.2.230.0060.01315.32
7.2.220.0040.01115.32
7.2.210.0000.01315.18
7.2.200.0110.00715.18
7.2.190.0100.00715.42
7.2.180.0090.00415.17
7.2.170.0040.01215.43
7.2.160.0030.00615.16
7.2.150.0000.01217.40
7.2.140.0080.00817.34
7.2.130.0040.00817.18
7.2.120.0040.00817.24
7.2.110.0490.01015.69
7.2.100.0190.00715.76
7.2.90.2560.00815.79
7.2.80.0140.00615.77
7.2.70.0190.01015.92
7.2.60.0370.00715.70
7.2.50.0110.00815.99
7.2.40.0700.00715.97
7.2.30.0350.00615.85
7.2.20.0130.00515.74
7.2.10.0480.00715.70
7.2.00.0070.00715.90
7.1.330.0030.00915.94
7.1.320.0030.01016.05
7.1.310.0030.01016.20
7.1.300.0070.00716.05
7.1.290.0060.00615.88
7.1.280.0070.00716.07
7.1.270.0060.00916.16
7.1.260.0060.00916.07
7.1.250.0040.00716.11
7.1.240.0000.01516.02
7.1.230.0490.00714.69
7.1.220.0410.00314.71
7.1.210.2790.00814.72
7.1.200.0380.00514.65
7.1.190.0170.00814.61
7.1.180.0920.00514.68
7.1.170.0090.00514.72
7.1.160.0130.00814.89
7.1.150.0170.00614.72
7.1.140.0630.00814.71
7.1.130.1140.00714.67
7.1.120.0730.00614.73
7.1.110.0110.00714.74
7.1.100.0290.00714.66
7.1.90.2760.00614.76
7.1.80.3040.00614.70
7.1.70.2580.00914.64
7.1.60.2400.00926.85
7.1.50.2910.00726.89
7.1.40.3510.01226.80
7.1.30.4780.01126.68
7.1.20.2630.00826.80
7.1.10.2420.00614.69
7.1.00.1860.00714.48
7.0.330.0030.01215.73
7.0.320.0040.00815.62
7.0.310.0040.01115.52
7.0.300.0030.00915.83
7.0.290.0090.00015.63
7.0.280.0070.00715.50
7.0.270.0000.01315.63
7.0.260.0030.01315.17
7.0.250.0060.00815.77
7.0.240.0060.00615.72
7.0.230.0060.00315.75
7.0.220.0060.00615.53
7.0.210.0060.00615.56
7.0.200.0030.00715.71
7.0.190.0060.00615.36
7.0.180.0030.01015.66
7.0.170.0050.00515.66
7.0.160.0100.00315.64
7.0.150.0090.00615.48
7.0.140.0040.00515.70
7.0.130.0000.01115.76
7.0.120.0080.00415.61
7.0.110.0000.00815.37
7.0.100.0000.01215.54
7.0.90.0040.00815.61
7.0.80.0040.00715.82
7.0.70.0070.00715.71
7.0.60.0060.00615.62
7.0.50.0040.00715.79
7.0.40.0030.00913.53
7.0.30.0080.00413.80
7.0.20.0000.01213.56
7.0.10.0040.00413.67
7.0.00.0000.01113.56
5.6.400.0000.01414.72
5.6.390.0030.00914.60
5.6.380.0050.01014.57
5.6.370.0100.00314.44
5.6.360.0030.00914.81
5.6.350.0080.00414.49
5.6.340.0060.00914.10
5.6.330.0060.01114.67
5.6.320.0150.00014.52
5.6.310.0080.01114.42
5.6.300.0030.01014.64
5.6.290.0040.01114.45
5.6.280.0040.00814.39
5.6.270.0000.01114.61
5.6.260.0070.00714.52
5.6.250.0070.00714.58
5.6.240.0040.00714.58
5.6.230.0030.01314.47
5.6.220.0000.01414.63
5.6.210.0060.00614.70
5.6.200.0100.00014.44
5.6.190.0030.00614.63
5.6.180.0120.00314.37
5.6.170.0120.00314.72
5.6.160.0050.00314.51
5.6.150.0070.01014.33
5.6.140.0030.01214.79
5.6.130.0040.00814.34
5.6.120.0060.00914.59
5.6.110.0080.00014.38
5.6.100.0000.00814.62
5.6.90.0100.00714.16
5.6.80.0070.00714.28
5.6.70.0120.00314.46
5.6.60.0040.01114.27
5.6.50.0000.01413.95
5.6.40.0040.00714.35
5.6.30.0060.00614.30
5.6.20.0030.01014.41
5.6.10.0080.00814.34
5.6.00.0000.01314.44

preferences:
165.23 ms | 403 KiB | 5 Q