3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Start sample $raw_str = '.....&lt;div&gt;&lt;/div&gt;<script></script>&amp; Weiß Göbel 中文百强网File name %20 %20 %21 %2C Décor \/. /. . z \... y \...... x ./ “This name” is & 462^^ not &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = that grrrreat -][09]()1234747) საბეჭდი-და-ტიპოგრაფიული'; $fallback_str = 'generated__' . date('Y-m-d_H-m_A'); $bad_extension = '....t&+++a()r.gz[]'; echo str_file($raw_str, '_', $bad_extension, $fallback_str); // End sample // Returns filesystem-safe string after cleaning, filtering, and trimming input function str_file_filter( $str, $sep = '_', $strict = false, $trim = 248) { $str = strip_tags(htmlspecialchars_decode(strtolower($str))); // lowercase -> decode -> strip tags $str = str_replace("%20", ' ', $str); // convert rogue %20 into spaces $str = preg_replace("/%[a-z0-9]{1,2}/i", '', $str); // remove hexy things $str = str_replace("&nbsp;", ' ', $str); // convert all nbsp into space $str = preg_replace("/&#?[a-z0-9]{2,8};/i", '', $str); // remove the other non-tag things $str = preg_replace("/\s+/", $sep, $str); // filter multiple spaces $str = preg_replace("/\.+/", '.', $str); // filter multiple periods $str = preg_replace("/^\.+/", '', $str); // trim leading period if ($strict) { $str = preg_replace("/([^\w\d\\" . $sep . ".])/", '', $str); // only allow words and digits } else { $str = preg_replace("/([^\w\d\\" . $sep . "\[\]\(\).])/", '', $str); // allow words, digits, [], and () } $str = preg_replace("/\\" . $sep . "+/", $sep, $str); // filter multiple separators $str = substr($str, 0, $trim); // trim filename to desired length, note 255 char limit on windows return $str; } // Returns full file name including fallback and extension function str_file( $str, $sep = '_', $ext = '', $default = '', $trim = 248) { // Run $str and/or $ext through filters to clean up strings $str = str_file_filter($str, $sep); $ext = '.' . str_file_filter($ext, '', true); // Default file name in case all chars are trimmed from $str, then ensure there is an id at tail if (empty($str) && empty($default)) { $str = 'no_name__' . date('Y-m-d_H-m_A') . '__' . uniqid(); } elseif (empty($str)) { $str = $default; } // Return completed string if (!empty($ext)) { return $str . $ext; } else { return $str; } }

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.0.200.0050.00417.25
7.4.290.0050.00716.69
7.4.270.0070.00216.86
7.4.100.0120.00816.82
7.4.90.0090.01116.72
7.4.80.0120.00616.82
7.4.70.0130.00616.53
7.4.60.0030.01316.66
7.4.50.0120.00817.07
7.4.40.0180.00016.96
7.4.30.0070.01416.57
7.4.20.0120.00816.63
7.4.10.0100.00715.99
7.4.00.0120.00716.03
7.3.220.0070.01416.73
7.3.210.0030.01316.93
7.3.200.0140.01416.68
7.3.190.0150.00316.49
7.3.180.0150.00316.62
7.3.170.0120.00616.64
7.3.160.0110.01116.68
7.3.150.0140.00516.90
7.3.140.0120.00616.88
7.3.130.0110.00815.94
7.3.120.0080.00916.00
7.3.110.0120.00515.94
7.3.100.0070.00916.12
7.3.90.0090.00715.90
7.3.80.0080.00816.07
7.3.70.0100.00615.60
7.3.60.0090.00815.75
7.3.50.0090.00715.66
7.3.40.0060.01015.59
7.3.30.0120.00715.67
7.3.20.0120.00616.27
7.3.10.0130.00916.26
7.3.00.0080.00916.14
7.2.330.0070.01116.99
7.2.320.0140.00317.02
7.2.310.0060.01217.07
7.2.300.0180.00017.00
7.2.290.0070.01117.10
7.2.280.0070.01116.86
7.2.270.0160.00316.93
7.2.260.0130.00716.31
7.2.250.0040.01715.89
7.2.240.0090.00716.25
7.2.230.0030.01416.33
7.2.220.0100.00516.15
7.2.210.0050.01316.16
7.2.200.0050.01115.82
7.2.190.0040.01215.74
7.2.180.0070.01115.82
7.2.170.0090.00715.89
7.2.160.0090.00915.72
7.2.150.0070.01016.33
7.2.140.0110.00916.51
7.2.130.0100.00716.37
7.2.120.0090.00816.44
7.2.110.0080.00916.50
7.2.100.0090.00816.49
7.2.90.0080.01016.49
7.2.80.0090.01116.60
7.2.70.0120.00816.50
7.2.60.0100.00916.46
7.2.50.0080.00916.44
7.2.40.0060.01016.63
7.2.30.0070.01216.59
7.2.20.0060.01116.37
7.2.10.0120.00616.48
7.2.00.0080.00816.56
7.1.330.0150.00715.93
7.1.320.0110.00916.07
7.1.310.0110.00715.89
7.1.300.0120.00815.42
7.1.290.0150.00315.50
7.1.280.0100.01315.37
7.1.270.0140.00715.36
7.1.260.0110.01115.29
7.1.250.0100.00915.48
7.1.240.0110.01015.36
7.1.230.0150.00615.31
7.1.220.0150.00615.33
7.1.210.0150.00515.45
7.1.200.0120.01015.42
7.1.190.0210.00115.41
7.1.180.0430.01315.42
7.1.170.0120.00915.40
7.1.160.0150.00815.35
7.1.150.0130.00615.42
7.1.140.0100.00915.39
7.1.130.0090.01015.40
7.1.120.0120.00815.35
7.1.110.0100.01115.47
7.1.100.0150.00515.33
7.1.90.0240.00915.46
7.1.80.0100.01015.48
7.1.70.0120.00615.97
7.1.60.0080.00916.00
7.1.50.0100.00915.88
7.1.40.0140.00815.87
7.1.30.0120.00815.79
7.1.20.0120.00815.90
7.1.10.0080.00815.84
7.1.00.0100.00815.88
7.0.330.0210.00514.61
7.0.320.0160.00714.64
7.0.310.0170.00614.54
7.0.300.0090.01314.66
7.0.290.0150.00914.75
7.0.280.0130.00914.69
7.0.270.0230.00614.56
7.0.260.0180.00614.64
7.0.250.0170.00514.63
7.0.240.0140.00914.71
7.0.230.0160.00914.61
7.0.220.0150.00614.67
7.0.210.0140.00814.64
7.0.200.0300.00815.56
7.0.190.0120.00715.49
7.0.180.0110.00615.35
7.0.170.0170.00315.33
7.0.160.0130.00615.34
7.0.150.0080.01015.43
7.0.140.0140.00415.45
7.0.130.0130.00515.37
7.0.120.0110.00715.51
7.0.110.0160.00615.32
7.0.100.0100.00815.46
7.0.90.0100.00715.44
7.0.80.0160.00315.36
7.0.70.0140.00715.34
7.0.60.0070.00815.22
7.0.50.0110.00814.71
7.0.40.0110.00614.65
7.0.30.0120.00614.60
7.0.20.0120.00814.69
7.0.10.0100.00714.68
7.0.00.0070.01314.62
5.6.400.0140.00615.27
5.6.390.0160.00515.29
5.6.380.0170.00815.40
5.6.370.0160.01215.54
5.6.360.0210.00615.32
5.6.350.0120.01515.25
5.6.340.0210.00415.35
5.6.330.0120.01015.19
5.6.320.0210.00315.55
5.6.310.0160.01115.45
5.6.300.0160.02617.00
5.6.290.0130.02317.14
5.6.280.0140.02217.40
5.6.270.0120.03717.20
5.6.260.0140.01917.22
5.6.250.0130.02017.17
5.6.240.0170.01617.22
5.6.230.0130.02017.17
5.6.220.0070.02617.08
5.6.210.0110.02417.09
5.6.200.0130.02216.99
5.6.190.0130.02117.20
5.6.180.0140.01917.19
5.6.170.0160.01817.08
5.6.160.0140.02117.14
5.6.150.0070.02617.14
5.6.140.0090.02417.17
5.6.130.0070.02416.98
5.6.120.0170.01617.15
5.6.110.0150.01817.27
5.6.100.0110.02417.08
5.6.90.0160.01817.04
5.6.80.0120.02116.71
5.6.70.0130.01716.80
5.6.60.0090.02016.96
5.6.50.0120.02016.76
5.6.40.0120.02016.89
5.6.30.0140.02116.94
5.6.20.0120.01916.89
5.6.10.0140.01917.01
5.6.00.0080.02516.92
5.5.380.0120.02116.06
5.5.370.0140.02215.96
5.5.360.0180.01716.06
5.5.350.0120.02315.94
5.5.340.0140.02116.22
5.5.330.0200.01416.11
5.5.320.0090.02516.25
5.5.310.0170.01616.20
5.5.300.0110.02416.22
5.5.290.0120.02116.13
5.5.280.0160.02216.27
5.5.270.0140.02016.14
5.5.260.0110.02216.01
5.5.250.0140.02016.20
5.5.240.0140.01716.06
5.5.230.0120.02115.91
5.5.220.0110.02015.84
5.5.210.0070.02615.83
5.5.200.0140.01915.81
5.5.190.0160.02415.83
5.5.180.0170.02115.78
5.5.170.0220.00515.05
5.5.160.0150.01915.97
5.5.150.0140.02116.04
5.5.140.0140.02015.84
5.5.130.0170.02115.92
5.5.120.0140.01815.92
5.5.110.0120.02215.93
5.5.100.0100.02015.80
5.5.90.0160.01815.78
5.5.80.0090.02315.84
5.5.70.0100.02115.92
5.5.60.0100.01815.86
5.5.50.0130.01815.82
5.5.40.0150.01715.91
5.5.30.0110.01915.90
5.5.20.0120.01715.92
5.5.10.0120.02015.58
5.5.00.0130.01615.76
5.4.450.0100.02014.58
5.4.440.0110.02014.56
5.4.430.0060.02214.57
5.4.420.0090.01814.57
5.4.410.0080.02314.55
5.4.400.0100.01914.43
5.4.390.0100.02114.45
5.4.380.0110.02614.38
5.4.370.0110.01514.37
5.4.360.0110.02914.33
5.4.350.0060.02214.45
5.4.340.0120.01814.30
5.4.330.0110.01212.05
5.4.320.0090.01914.45
5.4.310.0120.01614.37
5.4.300.0100.01814.48
5.4.290.0090.02114.52
5.4.280.0140.02214.54
5.4.270.0090.01814.42
5.4.260.0130.01414.43
5.4.250.0080.02114.33
5.4.240.0120.01614.39
5.4.230.0120.01814.49
5.4.220.0110.01714.42
5.4.210.0110.01714.39
5.4.200.0130.01614.40
5.4.190.0100.01814.45
5.4.180.0140.01714.34
5.4.170.0110.01714.36
5.4.160.0100.01514.41
5.4.150.0090.02114.41
5.4.140.0070.02013.70
5.4.130.0130.01413.59
5.4.120.0120.01413.62
5.4.110.0090.02113.59
5.4.100.0100.01713.59
5.4.90.0140.01913.65
5.4.80.0070.02113.55
5.4.70.0080.02013.66
5.4.60.0120.01513.56
5.4.50.0070.02013.62
5.4.40.0140.01413.59
5.4.30.0110.01813.70
5.4.20.0110.01513.49
5.4.10.0120.01713.51
5.4.00.0170.01713.48
5.3.290.0110.02013.28
5.3.280.0090.01913.19
5.3.270.0120.01913.26
5.3.260.0090.01713.27
5.3.250.0080.02013.21
5.3.240.0120.01613.30
5.3.230.0100.01713.15
5.3.220.0110.01613.09
5.3.210.0090.02213.10
5.3.200.0110.01913.08
5.3.190.0100.01813.08
5.3.180.0110.01613.10
5.3.170.0090.02313.17
5.3.160.0120.01613.12
5.3.150.0080.02313.15
5.3.140.0060.02013.24
5.3.130.0100.02013.12
5.3.120.0100.02613.19
5.3.110.0100.01913.17
5.3.100.0100.01613.13
5.3.90.0120.01613.17
5.3.80.0100.01713.07
5.3.70.0100.01713.06
5.3.60.0100.01713.13
5.3.50.0120.01513.13
5.3.40.0110.01813.12
5.3.30.0150.01613.16
5.3.20.0080.01813.09
5.3.10.0100.01813.07
5.3.00.0110.01913.05
5.2.170.0090.01412.75
5.2.160.0110.01212.77
5.2.150.0070.01612.75
5.2.140.0150.02112.77
5.2.130.0080.01412.69
5.2.120.0090.01312.71
5.2.110.0050.01912.73
5.2.100.0110.01612.71
5.2.90.0060.01612.73
5.2.80.0090.01512.68
5.2.70.0090.01412.67
5.2.60.0080.01412.72
5.2.50.0120.01012.76
5.2.40.0090.01312.68
5.2.30.0080.02112.67
5.2.20.0070.01412.66
5.2.10.0080.01312.69
5.2.00.0080.01412.64
5.1.60.0060.01212.64
5.1.50.0050.01612.64
5.1.40.0070.01112.64
5.1.30.0060.01512.64
5.1.20.0110.00912.64
5.1.10.0110.00912.64
5.1.00.0060.01612.64
5.0.50.0090.00712.64
5.0.40.0070.00912.64
5.0.30.0110.01712.64
5.0.20.0070.01112.64
5.0.10.0070.00812.64
5.0.00.0060.01512.64
4.4.90.0050.00812.64
4.4.80.0020.01012.64
4.4.70.0060.00612.64
4.4.60.0090.00512.64
4.4.50.0020.00912.64
4.4.40.0040.01512.64
4.4.30.0040.00912.64
4.4.20.0050.00712.64
4.4.10.0030.00812.64
4.4.00.0050.01012.64
4.3.110.0070.00612.64
4.3.100.0050.01512.64
4.3.90.0040.01512.64
4.3.80.0040.01112.64
4.3.70.0060.00612.64
4.3.60.0080.00512.64
4.3.50.0040.00812.64
4.3.40.0050.01112.64
4.3.30.0030.00912.64
4.3.20.0030.01112.64
4.3.10.0060.00812.64
4.3.00.0040.00712.64

preferences:
41.4 ms | 401 KiB | 5 Q