3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_allcaps($string) { $last_letter = mb_substr($string, -1, 1, 'UTF-8'); return $last_letter === mb_strtoupper($last_letter, 'UTF-8'); // otherwise use cytpe_upper() and setlocale() } function plural_to_singular($string) { // quick return of "untouchables" if(preg_match('~^(?:[oó]culos|parab[eé]ns|f[eé]rias)$~iu', $string)) { return $string; } $regex_map = [ '~[õã]es$~iu' => 'ão', '~(?:[áó].*e|[eé])is$~iu' => 'el', '~[^eé]\Kis$~iu' => 'l', '~ns$~iu' => 'm', '~eses$~iu' => 'ês', '~(?:[rzs]\Ke)?s$~iu' => '' ]; foreach ($regex_map as $pattern => $replacement) { $singular = preg_replace($pattern, $replacement, $string, 1, $count); if ($count) { return is_allcaps($string) ? mb_strtoupper($singular) : $singular; } } return $string; } $words = array( 'óculos' => 'óculos', 'papéis' => 'papel', 'anéis' => 'anel', 'PASTEIS' => 'PASTEL', 'CAMIÕES' => 'CAMIÃO', 'rodas' => 'roda', 'cães' => 'cão', 'meses' => 'mês', 'vezes' => 'vez', 'luzes' => 'luz', 'cristais' => 'cristal', 'canções' => 'canção', 'nuvens' => 'nuvem', 'alemães' => 'alemão' ); foreach($words as $plural => $singular) { echo "$plural => $singular = " , plural_to_singular($plural) , "\n"; }

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.4.130.0060.00518.03
8.4.120.0130.00820.63
8.4.110.0170.00418.97
8.4.100.0140.00818.03
8.4.90.0150.00620.37
8.4.80.0090.00420.67
8.4.70.0110.00919.08
8.4.60.0090.00820.67
8.4.50.0030.00620.64
8.4.40.0100.01019.01
8.4.30.0040.00417.83
8.4.20.0080.01520.39
8.4.10.0130.00320.71
8.3.260.0090.00416.66
8.3.250.0130.00618.81
8.3.240.0110.00716.81
8.3.230.0090.01017.04
8.3.220.0080.01118.86
8.3.210.0110.00716.85
8.3.200.0060.00316.75
8.3.190.0050.00417.09
8.3.180.0090.01218.99
8.3.170.0080.00017.25
8.3.160.0150.00317.13
8.3.150.0120.00617.28
8.3.140.0160.00617.27
8.3.130.0090.00618.49
8.3.120.0120.00620.72
8.3.110.0030.00620.94
8.3.100.0140.00424.06
8.3.90.0070.01126.77
8.3.80.0090.00018.56
8.3.70.0130.00318.74
8.3.60.0120.00918.55
8.3.50.0050.00917.67
8.3.40.0090.00618.96
8.3.30.0120.00318.82
8.3.20.0040.00421.90
8.3.10.0080.00020.82
8.3.00.0030.00617.63
8.2.290.0080.00817.23
8.2.280.0120.00720.43
8.2.270.0170.00317.02
8.2.260.0060.00317.12
8.2.250.0060.00317.16
8.2.240.0070.00317.49
8.2.230.0030.00622.58
8.2.220.0080.00437.54
8.2.210.0060.00326.77
8.2.200.0000.01118.66
8.2.190.0160.00316.70
8.2.180.0120.00316.88
8.2.170.0090.00622.96
8.2.160.0120.00322.30
8.2.150.0060.00324.18
8.2.140.0050.00524.66
8.2.130.0080.00026.16
8.2.120.0060.00319.84
8.2.110.0030.00622.39
8.2.100.0040.00818.03
8.2.90.0060.00318.03
8.2.80.0090.00019.14
8.2.70.0040.00417.93
8.2.60.0040.00417.99
8.2.50.0000.00818.10
8.2.40.0030.00619.34
8.2.30.0050.00219.35
8.2.20.0000.00718.13
8.2.10.0000.00719.48
8.2.00.0030.00518.22
8.1.330.0110.00716.59
8.1.320.0080.01216.38
8.1.310.0140.00416.82
8.1.300.0040.00418.07
8.1.290.0000.00930.84
8.1.280.0000.01525.92
8.1.270.0040.00420.33
8.1.260.0080.00026.35
8.1.250.0000.00828.09
8.1.240.0060.00323.77
8.1.230.0080.00422.62
8.1.220.0040.00417.77
8.1.210.0100.00518.92
8.1.200.0060.00317.60
8.1.190.0000.00917.48
8.1.180.0080.00018.10
8.1.170.0050.00318.84
8.1.160.0030.00519.16
8.1.150.0000.00819.16
8.1.140.0040.00419.14
8.1.130.0070.00020.37
8.1.120.0040.00417.64
8.1.110.0040.00417.74
8.1.100.0080.00017.74
8.1.90.0050.00317.57
8.1.80.0040.00417.66
8.1.70.0070.00017.73
8.1.60.0080.00417.79
8.1.50.0000.00817.68
8.1.40.0040.00717.66
8.1.30.0000.00817.80
8.1.20.0060.00317.75
8.1.10.0040.00417.67
8.1.00.0050.00317.63
8.0.300.0040.00420.12
8.0.290.0060.00316.88
8.0.280.0040.00418.55
8.0.270.0000.00716.98
8.0.260.0030.00318.60
8.0.250.0040.00417.20
8.0.240.0090.00017.11
8.0.230.0000.00817.13
8.0.220.0030.00317.30
8.0.210.0070.00017.32
8.0.200.0070.00017.23
8.0.190.0040.00417.21
8.0.180.0030.00517.16
8.0.170.0030.00517.27
8.0.160.0080.00317.19
8.0.150.0000.01017.16
8.0.140.0040.00417.19
8.0.130.0030.00313.57
8.0.120.0080.00017.12
8.0.110.0080.00017.11
8.0.100.0000.00717.08
8.0.90.0040.00417.08
8.0.80.0110.01217.20
8.0.70.0040.00417.34
8.0.60.0030.00517.26
8.0.50.0070.00017.13
8.0.30.0080.01017.46
8.0.20.0140.00817.28
8.0.10.0000.00817.24
8.0.00.0080.01117.15
7.4.330.0060.00015.55
7.4.320.0030.00316.79
7.4.300.0000.00716.96
7.4.290.0000.00716.95
7.4.280.0040.00416.99
7.4.270.0020.00516.75
7.4.260.0040.00416.84
7.4.250.0030.00316.88
7.4.240.0000.00716.98
7.4.230.0070.00016.75
7.4.220.0030.00516.93
7.4.210.0050.01016.97
7.4.200.0000.00716.77
7.4.160.0110.00816.81
7.4.140.0080.01017.86
7.4.130.0060.01216.64
7.4.120.0040.01916.62
7.4.110.0130.00616.88
7.4.100.0120.00616.68
7.4.90.0050.01616.84
7.4.80.0100.01419.39
7.4.70.0130.00416.65
7.4.60.0130.00316.76
7.4.50.0080.00816.55
7.4.40.0050.01516.89
7.4.10.0070.01115.18
7.4.00.0100.00915.15
7.3.330.0050.00013.78
7.3.320.0030.00313.71
7.3.310.0030.00316.72
7.3.300.0040.00416.59
7.3.290.0040.00416.59
7.3.280.0040.01116.73
7.3.260.0080.01116.73
7.3.230.0120.00916.84
7.3.210.0040.01216.78
7.3.200.0040.01916.63
7.3.190.0060.01616.92
7.3.180.0170.00316.57
7.3.170.0040.01816.81
7.3.160.0100.01116.81
7.3.130.0060.01314.90
7.3.120.0110.00715.08
7.3.110.0080.00615.24
7.3.100.0060.00914.97
7.3.90.0100.00215.20
7.3.80.0070.00615.05
7.3.70.0050.00715.00
7.3.60.0060.00715.11
7.3.50.0050.01114.92
7.3.40.0070.00815.00
7.3.30.0050.00815.12
7.3.20.0100.00616.86
7.3.10.0280.01116.53
7.3.00.0300.00616.40
7.2.330.0150.00316.89
7.2.320.0090.01116.90
7.2.310.0070.01016.77
7.2.300.0090.01216.80
7.2.290.0020.01716.92
7.2.260.0030.01715.39
7.2.250.0120.00715.36
7.2.240.0060.01115.28
7.2.230.0040.00815.33
7.2.220.0050.00915.22
7.2.210.0050.00815.37
7.2.200.0040.00715.27
7.2.190.0100.00515.30
7.2.180.0060.01015.25
7.2.170.0110.00315.26
7.2.160.0040.00715.08
7.2.150.0040.01117.04
7.2.140.0050.01417.10
7.2.130.0310.00716.33
7.2.120.0340.00916.63
7.2.110.0200.00916.49
7.2.100.0200.01116.51
7.2.90.0220.00616.62
7.2.80.0310.00816.71
7.2.70.0220.00616.59
7.2.60.0200.00716.57
7.2.50.0220.00616.54
7.2.40.0240.00416.72
7.2.30.0210.00616.55
7.2.20.0180.01016.63
7.2.10.0200.00916.66
7.2.00.0190.01016.50
7.1.330.0060.00916.05
7.1.320.0060.00716.05
7.1.310.0040.00716.03
7.1.300.0050.00915.97
7.1.290.0060.00816.00
7.1.280.0100.00716.00
7.1.270.0030.01216.11
7.1.260.0040.00916.02
7.1.250.0260.00615.54
7.1.240.0070.01016.11
7.1.230.0070.00716.15
7.1.220.0100.00316.06
7.1.210.0030.01115.96
7.1.200.0060.00616.14
7.1.190.0070.01016.04
7.1.180.0030.01316.03
7.1.170.0000.00915.90
7.1.160.0070.00716.03
7.1.150.0040.01216.10
7.1.140.0040.00816.18
7.1.130.0100.00616.17
7.1.120.0070.01015.83
7.1.110.0030.01316.16
7.1.100.0100.00316.13
7.1.90.0060.00616.11
7.1.80.0030.01216.20
7.1.70.0130.00316.02
7.1.60.0050.00516.16
7.1.50.0090.00615.89
7.1.40.0090.00615.86
7.1.30.0040.00816.17
7.1.20.0090.00616.07
7.1.10.0040.00815.77
7.1.00.0070.00416.07
5.6.400.0230.01015.95

preferences:
25.28 ms | 403 KiB | 5 Q