3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = '<p>\' ‘ ’ ‚ " “ ” „ &amp;amp; © ® ™ ° &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>'; echo clean($str); echo PHP_EOL.PHP_EOL; $htmlent = htmlentities($str, ENT_HTML5 | ENT_QUOTES, 'UTF-8'); echo $htmlent; echo PHP_EOL.PHP_EOL; echo htmlentity_decode($htmlent); function clean($str_clean, $strict_clean = true, $punct_clean = true) { $base_pool = array( '‘' => '&lsquo;', '’' => '&rsquo;', '‚' => '&sbquo;', '“' => '&ldquo;', '”' => '&rdquo;', '„' => '&bdquo;', '©' => '&copy;', '®' => '&reg;', '™' => '&trade;', '°' => '&deg;', '•' => '&bull;', '–' => '&ndash;', '—' => '&mdash;', '…' => '&#8230;', '¼' => '&#188;', '½' => '&#189;', '¾' => '&#190;', '‰' => '&#8240;', '±' => '&#177;', '†' => '&#8224;', '‡' => '&#8225;', '&amp;amp;' => '&amp;', '&nbsp;' => ' ' ); $strict_pool = array( '\'' => '&#39;', '"' => '&quot;', "\r" => ' ', "\n" => ' ', "\t" => ' ' ); // if strict param is true we will clean harder (default true) if ($strict_clean) { $base_pool = array_merge($strict_pool, $base_pool); } foreach ($base_pool as $key => $value) { $str_clean = str_replace($key, $value, $str_clean); // iterate through pool key => values and replace in $str_clean } // if punct param is true we will add spaces after punctuation (default true) if ($punct_clean) { $str_clean = preg_replace('/([!?,.])(\S)/', '$1 $2', $str_clean); // parse punctuation and add trail space } $str_clean = preg_replace("/\s+/", ' ', $str_clean); // filter multiple spaces into single return $str_clean; }

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.0150.00618.55
8.3.50.0140.00018.13
8.3.40.0120.00318.96
8.3.30.0070.01118.92
8.3.20.0040.00420.27
8.3.10.0050.00320.78
8.3.00.0040.00423.36
8.2.180.0100.00716.75
8.2.170.0110.00722.96
8.2.160.0120.00322.19
8.2.150.0030.00624.18
8.2.140.0000.00824.66
8.2.130.0030.00721.04
8.2.120.0040.00426.35
8.2.110.0000.00921.06
8.2.100.0070.00317.91
8.2.90.0030.00619.28
8.2.80.0080.00017.97
8.2.70.0080.00017.63
8.2.60.0040.00417.93
8.2.50.0030.00618.10
8.2.40.0040.00420.54
8.2.30.0080.00019.46
8.2.20.0000.00717.87
8.2.10.0000.00818.05
8.2.00.0000.00718.16
8.1.280.0070.01125.92
8.1.270.0090.00922.01
8.1.260.0080.00028.09
8.1.250.0080.00028.09
8.1.240.0030.00623.96
8.1.230.0040.00719.48
8.1.220.0040.00417.74
8.1.210.0000.01218.77
8.1.200.0050.00517.48
8.1.190.0030.00617.35
8.1.180.0040.00418.10
8.1.170.0040.00418.73
8.1.160.0050.00320.72
8.1.150.0060.00318.79
8.1.140.0030.00519.50
8.1.130.0070.00017.81
8.1.120.0050.00317.69
8.1.110.0040.00417.53
8.1.100.0000.00717.60
8.1.90.0040.00417.69
8.1.80.0040.00417.69
8.1.70.0070.00017.68
8.1.60.0000.00817.64
8.1.50.0080.00017.74
8.1.40.0040.00417.68
8.1.30.0030.00517.83
8.1.20.0040.00417.69
8.1.10.0000.00817.65
8.1.00.0040.00417.64
8.0.300.0030.00618.77
8.0.290.0080.00016.87
8.0.280.0040.00418.53
8.0.270.0000.00717.23
8.0.260.0030.00617.35
8.0.250.0000.00717.23
8.0.240.0000.00717.08
8.0.230.0000.00717.18
8.0.220.0070.00017.11
8.0.210.0000.00717.02
8.0.200.0030.00317.15
8.0.190.0040.00417.05
8.0.180.0030.00617.05
8.0.170.0040.00417.17
8.0.160.0000.00817.09
8.0.150.0040.00417.04
8.0.140.0020.00517.12
8.0.130.0060.00313.58
8.0.120.0000.00817.00
8.0.110.0000.00717.03
8.0.100.0000.00716.99
8.0.90.0040.00417.11
8.0.80.0030.01217.18
8.0.70.0040.00416.91
8.0.60.0040.00417.13
8.0.50.0000.00717.02
8.0.30.0110.00517.42
8.0.20.0080.01017.47
8.0.10.0000.00817.14
8.0.00.0090.01416.89
7.4.330.0000.00616.83
7.4.320.0040.00416.64
7.4.300.0030.00316.74
7.4.290.0000.00816.85
7.4.280.0040.00416.87
7.4.270.0030.00316.88
7.4.260.0040.00416.64
7.4.250.0040.00416.71
7.4.240.0050.00216.88
7.4.230.0050.00216.88
7.4.220.0030.01716.75
7.4.210.0170.00016.69
7.4.200.0050.00216.82
7.4.160.0080.00816.83
7.4.150.0110.00617.40
7.4.140.0130.00817.86
7.4.130.0140.00616.80
7.4.120.0100.01016.81
7.4.110.0070.01116.75
7.4.100.0160.00716.64
7.4.90.0070.01116.88
7.4.80.0070.01019.39
7.4.70.0100.00616.89
7.4.60.0150.00316.86
7.4.50.0040.00716.78
7.4.40.0090.00916.61
7.4.30.0120.00616.63
7.4.10.0130.00615.25
7.4.00.0100.00515.19
7.3.330.0050.00013.54
7.3.320.0030.00313.61
7.3.310.0040.00416.64
7.3.300.0070.00016.45
7.3.290.0060.01116.53
7.3.280.0100.00916.58
7.3.270.0140.00317.40
7.3.260.0090.00916.68
7.3.250.0090.01016.64
7.3.240.0080.00916.55
7.3.230.0130.00616.72
7.3.210.0090.00916.94
7.3.200.0060.01116.85
7.3.190.0090.00816.82
7.3.180.0030.01716.68
7.3.170.0040.01216.68
7.3.160.0030.01716.67
7.3.130.0040.01415.11
7.3.120.0000.01615.07
7.3.110.0030.01615.19
7.3.100.0040.00814.98
7.3.90.0070.00714.91
7.3.80.0000.01314.74
7.3.70.0070.00715.12
7.3.60.0030.00914.91
7.3.50.0030.00815.17
7.3.40.0090.00015.10
7.3.30.0060.00615.14
7.3.20.0070.01016.76
7.3.10.0000.01316.88
7.3.00.0000.00916.95
7.2.330.0090.00916.77
7.2.320.0150.00716.85
7.2.310.0100.00716.91
7.2.300.0060.01216.71
7.2.290.0120.00916.84
7.2.260.0090.00915.37
7.2.250.0110.00714.99
7.2.240.0000.01415.37
7.2.230.0110.00615.45
7.2.220.0130.00315.19
7.2.210.0000.01515.26
7.2.200.0110.00415.32
7.2.190.0120.00315.36
7.2.180.0090.00615.09
7.2.170.0000.01515.27
7.2.160.0130.00315.12
7.2.150.0080.00817.13
7.2.140.0000.01217.01
7.2.130.0030.00617.10
7.2.120.0090.00616.86
7.2.110.0040.01217.14
7.2.100.0030.01017.21
7.2.90.0070.01017.33
7.2.80.0070.01117.23
7.2.70.0050.00517.17
7.2.60.0060.00617.13
7.2.50.0030.00917.20
7.2.40.0090.00617.09
7.2.30.0040.00817.21
7.2.20.0030.00617.09
7.2.10.0070.01016.85
7.2.00.0030.00918.45
7.1.330.0070.00716.13
7.1.320.0000.01216.01
7.1.310.0070.01015.79
7.1.300.0100.00315.74
7.1.290.0100.00315.94
7.1.280.0030.01516.15
7.1.270.0100.00716.11
7.1.260.0070.00715.99
7.1.250.0070.00715.95
7.1.240.0030.01416.10
7.1.230.0100.00715.87
7.1.220.0030.00615.83
7.1.210.0070.01015.73
7.1.200.0090.00416.07
7.1.190.0040.00416.16
7.1.180.0090.00315.83
7.1.170.0060.00915.99
7.1.160.0000.00915.88
7.1.150.0060.00315.84
7.1.140.0000.01116.11
7.1.130.0080.00816.05
7.1.120.0060.01216.00
7.1.110.0090.00616.16
7.1.100.0070.00717.30
7.1.90.0000.01516.15
7.1.80.0030.01015.98
7.1.70.0030.01416.72
7.1.60.0080.01017.60
7.1.50.0070.00716.71
7.1.40.0040.00416.20
7.1.30.0040.00416.12
7.1.20.0040.00815.73
7.1.10.0080.00816.07
7.1.00.0070.04019.23
7.0.330.0110.00415.73
7.0.320.0080.00415.66
7.0.310.0090.00315.71
7.0.300.0070.00715.54
7.0.290.0080.00015.34
7.0.280.0090.00615.65
7.0.270.0030.01015.29
7.0.260.0090.00915.64
7.0.250.0070.00315.70
7.0.240.0030.00915.70
7.0.230.0070.00715.41
7.0.220.0040.00815.69
7.0.210.0070.00415.46
7.0.200.0260.00815.18
7.0.190.0080.00815.69
7.0.180.0070.00715.80
7.0.170.0030.00615.50
7.0.160.0070.00715.38
7.0.150.0100.00615.61
7.0.140.0150.00015.49
7.0.130.0030.00715.66
7.0.120.0030.00915.70
7.0.110.0090.00315.71
7.0.100.0000.01215.64
7.0.90.0050.00515.29
7.0.80.0120.00315.72
7.0.70.0070.00715.78
7.0.60.0120.03518.67
7.0.50.0040.02916.74
7.0.40.0020.04516.85
7.0.30.0120.04217.08
7.0.20.0150.03217.03
7.0.10.0050.05116.97
7.0.00.0050.02716.79
5.6.400.0070.00714.65
5.6.390.0040.01114.27
5.6.380.0080.00814.59
5.6.370.0040.01214.65
5.6.360.0070.01114.02
5.6.350.0030.00714.64
5.6.340.0040.01114.22
5.6.330.0040.01114.39
5.6.320.0070.00314.51
5.6.310.0070.00714.32
5.6.300.0070.01014.70
5.6.290.0000.00814.27
5.6.280.0080.03617.56
5.6.270.0060.00614.38
5.6.260.0000.01514.50
5.6.250.0030.00614.34
5.6.240.0090.00614.28
5.6.230.0100.00614.42
5.6.220.0080.00414.38
5.6.210.0080.02217.59
5.6.200.0090.04616.35
5.6.190.0070.03717.62
5.6.180.0110.02517.51
5.6.170.0180.03717.41
5.6.160.0040.03117.46
5.6.150.0070.04516.33
5.6.140.0070.04016.33
5.6.130.0090.04016.30
5.6.120.0050.04717.51
5.6.110.0080.04617.71
5.6.100.0050.02817.89
5.6.90.0070.04517.80
5.6.80.0080.04017.24
5.6.70.0090.00614.56
5.6.60.0000.01614.39
5.6.50.0100.00714.54
5.6.40.0060.00914.30
5.6.30.0040.00714.55
5.6.20.0030.01014.46
5.6.10.0040.01114.27
5.6.00.0100.00714.35
5.5.380.0100.00714.47
5.5.370.0060.00914.06
5.5.360.0050.00514.04
5.5.350.0180.04017.39
5.5.340.0070.03516.07
5.5.330.0090.04217.30
5.5.320.0200.03217.37
5.5.310.0170.03817.27
5.5.300.0060.03516.01
5.5.290.0090.04516.26
5.5.280.0070.04017.54
5.5.270.0070.03317.48
5.5.260.0050.02417.63
5.5.250.0070.02517.60
5.5.240.0050.04017.04
5.5.230.0060.01014.14
5.5.220.0050.01014.31
5.5.210.0060.00613.96
5.5.200.0040.00414.49
5.5.190.0040.00414.43
5.5.180.0040.00914.09
5.5.170.0000.01514.38
5.5.160.0060.01313.98
5.5.150.0030.01414.17
5.5.140.0080.00314.42
5.5.130.0000.01114.20
5.5.120.0000.01114.04
5.5.110.0110.00414.08
5.5.100.0070.00414.32
5.5.90.0030.01314.17
5.5.80.0040.01114.49
5.5.70.0070.01114.34
5.5.60.0090.00614.29
5.5.50.0070.00714.05
5.5.40.0090.00314.41
5.5.30.0060.00614.13
5.5.20.0060.00614.46
5.5.10.0000.01113.89
5.5.00.0070.00714.05

preferences:
63.17 ms | 401 KiB | 5 Q