3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Refinery29\Core; final class Util { const R29STATIC_DOMAIN = 's%d.r29static.com'; /** * @param string $text * @param string $spacer * * @return array|mixed|string */ public static function tagify($text, $spacer = '-') { //Handle if array if (is_array($text)) { return array_map("self::tagify", $text); } $text = self::decodeHtml($text); $text = self::normalizeStr($text); $text = str_replace('&', 'and', $text); return str_replace(' ', $spacer, trim(preg_replace('#([^a-z0-9/]+)#', ' ', strtolower($text)))); } /** * @param string $text * * @return string */ public static function decodeHtml($text) { return html_entity_decode($text, ENT_QUOTES, 'UTF-8'); } /** * @param string $text * * @return string */ public static function normalizeStr($text) { $map = [ 'Š' => 'S', 'š' => 's', 'Ð' => 'Dj','Ž' => 'Z', 'ž' => 'z', 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Ä' => 'A', 'Å' => 'A', 'Æ' => 'A', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'O', 'Ø' => 'O', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ü' => 'U', 'Ý' => 'Y', 'Þ' => 'B', 'ß' => 'Ss','à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a', 'ä' => 'a', 'å' => 'a', 'æ' => 'a', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e', 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'o', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 'ø' => 'o', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ý' => 'y', 'ý' => 'y', 'þ' => 'b', 'ÿ' => 'y', 'ƒ' => 'f', ]; return strtr($text, $map); } /** * @param $path * @param mixed|string $app * @param string $scheme * * @return string */ public static function r29StaticAlias($path, $app = APP_NAME, $scheme = null) { // there is no bin app, bin is passed for images served by the cms if ($app === 'bin') { $path = preg_replace('#^/static/#', '/', $path); } else { $path = sprintf('%s/%s/%s', $app, rev(), $path); } $domain = sprintf(Util::R29STATIC_DOMAIN, Util::hashmod($path, 3) + 1); $url = sprintf('//%s/%s', $domain, $path); if (! empty($scheme) && strpos($url, 'http') !== 0) { $url = sprintf('%s:%s', $scheme, $url); } return $url; } /** * @param $str * @param $max * * @return int */ public static function hashmod($str, $max) { return crc32($str) % $max; } } var_dump(Refinery29\Core\Util::tagify(['sethomg john', 'yolo oko']));

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.0140.00718.30
8.3.50.0090.00616.20
8.3.40.0180.00418.73
8.3.30.0150.00018.84
8.3.20.0050.00320.16
8.3.10.0000.00821.65
8.3.00.0000.00820.11
8.2.180.0160.00318.41
8.2.170.0110.00322.96
8.2.160.0090.00620.77
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00317.38
8.2.110.0070.01119.30
8.2.100.0070.00717.84
8.2.90.0000.00819.05
8.2.80.0040.00417.97
8.2.70.0030.00617.50
8.2.60.0030.00518.04
8.2.50.0090.00018.10
8.2.40.0000.00919.34
8.2.30.0000.00720.74
8.2.20.0080.00017.80
8.2.10.0000.00717.98
8.2.00.0000.00718.10
8.1.280.0040.01125.92
8.1.270.0060.00323.91
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00322.16
8.1.230.0090.00317.77
8.1.220.0000.00817.74
8.1.210.0030.00518.77
8.1.200.0030.00617.10
8.1.190.0000.00817.23
8.1.180.0000.00818.10
8.1.170.0040.00418.61
8.1.160.0040.00421.92
8.1.150.0040.00418.83
8.1.140.0050.00317.30
8.1.130.0000.00717.61
8.1.120.0000.00817.39
8.1.110.0000.00717.42
8.1.100.0090.00017.43
8.1.90.0000.00817.29
8.1.80.0050.00317.29
8.1.70.0070.00017.41
8.1.60.0050.00317.54
8.1.50.0040.00417.40
8.1.40.0030.00617.36
8.1.30.0030.00617.69
8.1.20.0060.00317.64
8.1.10.0000.00817.52
8.1.00.0000.00817.46
8.0.300.0040.00418.77
8.0.290.0000.00916.63
8.0.280.0030.00318.45
8.0.270.0000.00817.27
8.0.260.0060.00017.24
8.0.250.0030.00616.96
8.0.240.0030.00317.01
8.0.230.0050.00317.05
8.0.220.0020.00516.82
8.0.210.0000.00816.93
8.0.200.0030.00317.07
8.0.190.0030.00517.01
8.0.180.0110.00016.89
8.0.170.0040.00416.88
8.0.160.0040.00416.99
8.0.150.0030.00316.91
8.0.140.0000.00716.90
8.0.130.0060.00013.37
8.0.120.0070.00016.91
8.0.110.0050.00216.99
8.0.100.0050.00316.77
8.0.90.0000.00716.81
8.0.80.0100.00717.03
8.0.70.0040.00416.94
8.0.60.0050.00217.00
8.0.50.0030.00516.97
8.0.30.0130.00917.13
8.0.20.0160.00617.40
8.0.10.0000.00916.98
8.0.00.0100.00716.74
7.4.330.0060.00015.08
7.4.320.0000.00616.52
7.4.300.0040.00416.60
7.4.290.0050.00316.57
7.4.280.0040.00416.47
7.4.270.0000.00716.56
7.4.260.0000.00716.46
7.4.250.0040.00416.52
7.4.240.0020.00516.48
7.4.230.0040.00416.67
7.4.220.0060.01216.66
7.4.210.0120.00916.37
7.4.200.0070.00016.66
7.4.160.0040.01216.70
7.4.150.0070.01017.40
7.4.140.0100.01017.86
7.4.130.0060.01416.53
7.4.120.0080.00916.50
7.4.110.0100.00716.59
7.4.100.0110.00716.49
7.4.90.0100.00716.41
7.4.80.0130.00619.39
7.4.70.0110.00616.52
7.4.60.0080.00816.51
7.4.50.0000.00916.34
7.4.40.0130.00316.68
7.4.30.0000.01816.59
7.4.00.0070.00714.91
7.3.330.0030.00313.28
7.3.320.0050.00013.28
7.3.310.0000.00716.32
7.3.300.0030.00316.22
7.3.290.0090.00816.31
7.3.280.0080.01116.37
7.3.270.0120.00617.40
7.3.260.0060.01116.52
7.3.250.0100.01016.42
7.3.240.0070.01716.57
7.3.230.0100.01416.39
7.3.210.0070.01016.42
7.3.200.0070.01116.61
7.3.190.0110.00716.32
7.3.180.0070.01016.32
7.3.170.0100.01416.51
7.3.160.0030.01716.53
7.3.120.0070.01014.93
7.3.110.0110.00715.04
7.3.100.0070.00715.05
7.3.90.0060.00914.84
7.3.80.0040.01114.84
7.3.70.0100.00314.81
7.3.60.0030.00714.73
7.3.50.0040.00814.93
7.3.40.0030.01214.70
7.3.30.0030.01214.81
7.3.20.0040.00716.59
7.3.10.0060.00916.61
7.3.00.0030.00716.73
7.2.330.0030.01316.62
7.2.320.0070.01016.67
7.2.310.0040.01816.81
7.2.300.0040.01416.39
7.2.290.0060.01116.24
7.2.250.0080.01114.87
7.2.240.0070.01114.84
7.2.230.0070.01015.09
7.2.220.0000.01015.14
7.2.210.0040.01115.01
7.2.200.0060.00615.11
7.2.190.0030.01215.13
7.2.180.0000.01114.91
7.2.170.0060.00615.11
7.2.60.0070.00716.55
7.2.00.0100.00319.19
7.1.330.0080.00815.62
7.1.320.0000.01315.69
7.1.310.0040.01115.70
7.1.300.0070.00415.63
7.1.290.0070.00615.69
7.1.280.0120.00615.77
7.1.270.0070.00315.73
7.1.260.0100.00315.66
7.1.200.0000.01615.73
7.1.100.0000.01118.03
7.1.70.0000.00716.75
7.1.60.0170.00719.11
7.1.50.0120.01216.90
7.1.00.0100.06722.33
7.0.200.0040.00416.69
7.0.60.0070.08719.98
7.0.50.0070.08317.98
7.0.40.0030.05020.23
7.0.30.0300.07720.13
7.0.20.0330.05720.08
7.0.10.0030.05320.29
7.0.00.0030.06720.05
5.6.280.0070.07021.14
5.6.210.0030.08020.65
5.6.200.0130.06718.20
5.6.190.0100.08720.48
5.6.180.0330.07020.42
5.6.170.0270.07320.56
5.6.160.0070.08320.41
5.6.150.0100.06318.23
5.6.140.0070.04718.20
5.6.130.0100.07718.18
5.6.120.0070.03721.01
5.6.110.0030.08720.99
5.6.100.0070.08020.93
5.6.90.0100.05021.12
5.6.80.0130.07720.54
5.5.350.0030.04020.54
5.5.340.0030.07318.04
5.5.330.0070.04020.45
5.5.320.0200.06320.34
5.5.310.0400.06720.36
5.5.300.0130.07718.02
5.5.290.0070.04018.01
5.5.280.0030.04320.82
5.5.270.0030.05020.84
5.5.260.0030.08720.92
5.5.250.0170.05020.75
5.5.240.0200.04020.23
5.4.450.0900.06019.42
5.4.440.0900.06319.59
5.4.430.0800.06019.30
5.4.420.1070.06319.20
5.4.410.1100.05719.43
5.4.400.1000.06319.02
5.4.390.1070.05719.05
5.4.380.1100.05319.13
5.4.370.1070.04019.26
5.4.360.0930.05719.12
5.4.350.1070.05719.14
5.4.340.0970.06319.16
5.4.320.1030.05718.98
5.4.310.0870.06018.88
5.4.300.0900.06319.38
5.4.290.1000.06019.26
5.4.280.1100.05319.26
5.4.270.1370.04719.13
5.4.260.1270.06319.25
5.4.250.0930.06019.27
5.4.240.1070.06019.15
5.4.230.0970.05719.25
5.4.220.1100.05719.30
5.4.210.1030.07019.13
5.4.200.0930.06019.37
5.4.190.0930.05719.05
5.4.180.1000.07019.11
5.4.170.0930.07018.95
5.4.160.0900.05019.11
5.4.150.0870.05019.13
5.4.140.0770.05016.42
5.4.130.0670.05016.55
5.4.120.0730.05716.54
5.4.110.0830.05316.57
5.4.100.0900.04716.32
5.4.90.0800.05716.42
5.4.80.0800.07016.64
5.4.70.0070.07016.52
5.4.60.0030.07016.36
5.4.50.0070.03716.39
5.4.40.0330.04716.55
5.4.30.0270.06716.52
5.4.20.0330.03016.18

preferences:
50.31 ms | 400 KiB | 5 Q