3v4l.org

run code in 300+ PHP versions simultaneously
<?php function plural_to_singular($string) { // quick return of "un-convertibles" if(preg_match('~^(?:[oó]culos|parab[eé]ns|f[eé]rias)$~iu', $string)) { return $string; } $regex_config = [ '~[õã]es$~iu' => 'ão', '~[áó].*eis$~iu' => 'el', '~[eé]is$~iu' => 'el', '~[^eé]\Kis$~iu' => 'l', '~ns$~iu' => 'm', '~eses$~iu' => 'ês', '~[rzs]\Kes$~iu' => '', '~s$~iu' => '' ]; return preg_replace(array_keys($regex_config), $regex_config, $string, 1); } $words = array( '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.0120.00817.70
8.4.120.0090.00720.65
8.4.110.0140.00822.39
8.4.100.0130.00818.01
8.4.90.0050.00619.71
8.4.80.0050.00618.10
8.4.70.0140.00817.98
8.4.60.0110.00918.91
8.4.50.0070.00919.97
8.4.40.0040.00417.89
8.4.30.0130.00717.92
8.4.20.0170.00720.55
8.4.10.0030.00620.63
8.3.260.0060.00417.01
8.3.250.0040.00518.65
8.3.240.0110.00917.07
8.3.230.0100.00816.99
8.3.220.0110.00117.23
8.3.210.0160.00416.77
8.3.200.0060.00316.80
8.3.190.0040.00617.20
8.3.180.0100.00816.52
8.3.170.0090.00917.20
8.3.160.0070.01316.84
8.3.150.0110.01118.91
8.3.140.0110.01117.21
8.3.130.0070.01316.92
8.3.120.0100.00618.93
8.3.110.0040.00420.94
8.3.100.0160.00324.06
8.3.90.0070.01126.77
8.3.80.0060.00318.55
8.3.70.0040.01917.13
8.3.60.0040.01518.68
8.3.50.0140.00417.76
8.3.40.0120.00319.10
8.3.30.0090.00618.96
8.3.20.0070.00021.89
8.3.10.0080.00020.52
8.3.00.0060.00317.63
8.2.290.0130.00620.65
8.2.280.0120.00618.27
8.2.270.0000.01918.49
8.2.260.0080.00018.80
8.2.250.0040.01416.76
8.2.240.0090.00017.13
8.2.230.0080.00022.58
8.2.220.0100.00337.54
8.2.210.0090.00626.77
8.2.200.0060.00316.88
8.2.190.0110.00717.00
8.2.180.0070.00725.92
8.2.170.0080.00819.26
8.2.160.0070.00722.96
8.2.150.0040.00425.66
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00826.16
8.2.110.0000.01022.31
8.2.100.0090.00318.09
8.2.90.0030.00617.88
8.2.80.0050.00318.04
8.2.70.0030.00618.03
8.2.60.0000.00918.03
8.2.50.0030.00518.10
8.2.40.0040.00419.30
8.2.30.0040.00419.22
8.2.20.0000.00818.16
8.2.10.0040.00419.48
8.2.00.0050.00518.22
8.1.330.0060.00420.38
8.1.320.0140.00616.23
8.1.310.0040.00416.67
8.1.300.0000.00919.97
8.1.290.0060.00330.84
8.1.280.0100.00725.92
8.1.270.0050.00324.66
8.1.260.0090.00026.35
8.1.250.0040.00428.09
8.1.240.0060.00323.96
8.1.230.0060.00619.08
8.1.220.0040.00417.79
8.1.210.0110.00018.77
8.1.200.0070.00317.48
8.1.190.0000.00817.48
8.1.180.0030.00518.10
8.1.170.0040.00418.76
8.1.160.0000.00719.06
8.1.150.0000.00818.87
8.1.140.0040.00419.03
8.1.130.0070.00020.18
8.1.120.0040.00417.54
8.1.110.0050.00317.63
8.1.100.0040.00417.61
8.1.90.0070.00017.53
8.1.80.0000.00817.62
8.1.70.0030.00317.53
8.1.60.0060.00317.62
8.1.50.0060.00317.65
8.1.40.0000.00817.68
8.1.30.0000.00917.79
8.1.20.0000.00817.79
8.1.10.0000.00817.71
8.1.00.0050.00317.58
8.0.300.0040.00419.93
8.0.290.0040.00416.88
8.0.280.0000.00718.40
8.0.270.0000.00717.30
8.0.260.0030.00318.44
8.0.250.0030.00317.16
8.0.240.0000.00717.07
8.0.230.0000.00817.22
8.0.220.0050.00317.19
8.0.210.0040.00417.18
8.0.200.0030.00317.14
8.0.190.0000.00717.21
8.0.180.0030.00617.06
8.0.170.0060.00317.18
8.0.160.0070.00317.24
8.0.150.0030.00617.04
8.0.140.0040.00417.11
8.0.130.0000.00613.56
8.0.120.0040.00417.20
8.0.110.0030.00517.18
8.0.100.0070.00017.14
8.0.90.0000.00717.25
8.0.80.0080.01617.10
8.0.70.0030.00517.18
8.0.60.0040.00417.13
8.0.50.0000.00817.07
8.0.30.0120.00917.06
8.0.20.0130.00617.50
8.0.10.0050.00217.14
8.0.00.0060.01416.92
7.4.330.0000.00515.55
7.4.320.0000.00616.82
7.4.300.0040.00416.88
7.4.290.0080.00016.88
7.4.280.0060.00316.88
7.4.270.0040.00416.79
7.4.260.0040.00416.70
7.4.250.0040.00416.77
7.4.240.0080.00016.75
7.4.230.0000.00816.92
7.4.220.0030.00516.68
7.4.210.0110.00716.89
7.4.200.0000.00816.88
7.4.160.0120.00616.85
7.4.130.0040.01416.75
7.4.120.0070.01116.78
7.4.110.0110.00816.86
7.4.100.0110.00616.81
7.4.90.0100.00716.84
7.4.80.0140.00819.39
7.4.70.0100.01416.92
7.4.60.0060.01016.59
7.4.50.0070.00716.69
7.4.40.0060.01116.99
7.4.00.0070.01115.22
7.3.330.0000.00613.59
7.3.320.0000.00613.42
7.3.310.0030.00316.70
7.3.300.0070.00016.60
7.3.290.0040.00416.64
7.3.280.0110.01016.57
7.3.260.0110.01016.73
7.3.240.0090.01016.61
7.3.230.0070.01116.56
7.3.210.0140.00716.45
7.3.200.0030.01416.57
7.3.190.0140.01016.55
7.3.180.0090.00916.77
7.3.170.0130.00316.48
7.3.160.0130.00316.46
7.3.120.0080.00815.26
7.3.110.0080.00715.25
7.3.100.0120.00514.99
7.3.90.0050.00915.07
7.3.80.0070.00515.01
7.3.70.0090.00415.00
7.3.60.0050.00915.17
7.3.50.0020.01415.00
7.3.40.0090.00515.17
7.3.30.0070.00515.01
7.3.20.0080.00316.86
7.3.10.0180.00416.27
7.3.00.0160.01016.38
7.2.330.0040.01316.73
7.2.320.0040.01717.00
7.2.310.0040.01316.86
7.2.300.0040.01416.80
7.2.290.0120.01216.77
7.2.250.0070.01115.30
7.2.240.0100.00815.29
7.2.230.0070.00915.29
7.2.220.0080.00715.20
7.2.210.0050.01015.18
7.2.200.0050.00915.34
7.2.190.0050.01015.12
7.2.180.0080.00615.00
7.2.170.0080.00615.07
7.2.160.0000.01514.96
7.2.150.0060.01017.13
7.2.140.0070.01017.07
7.2.130.0190.00816.06
7.2.120.0340.00516.09
7.2.110.0250.00516.13
7.2.100.0310.01216.11
7.2.90.0200.00616.15
7.2.80.0150.00916.09
7.2.70.0200.00316.11
7.2.60.0160.00716.20
7.2.50.0140.01116.09
7.2.40.0230.01215.97
7.2.30.0220.00816.29
7.2.20.0260.00516.03
7.2.10.0210.00216.08
7.2.00.0140.01216.26
7.1.330.0060.00716.11
7.1.320.0060.00616.10
7.1.310.0060.00615.95
7.1.300.0040.00915.93
7.1.290.0050.00715.97
7.1.280.0070.00315.85
7.1.270.0080.00715.92
7.1.260.0050.00816.07
7.1.250.0140.00714.95

preferences:
27.81 ms | 403 KiB | 5 Q