3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = [ ['this is a test', 'This Is a Test', false], ['why sunless tanning is A hot trend', 'Why Sunless Tanning Is a Hot Trend', false], ['Satin Sheets are a Luxury you Can Afford', 'Satin Sheets Are a Luxury You Can Afford', false], ['the Dangers Of Hiking Without Proper Shoes', 'The Dangers of Hiking Without Proper Shoes', false], ['an hour or so', 'An Hour or So', false], ['Of the meaning Of Of', 'Of the Meaning of Of', false], ['Thing With Extra Spaces', 'Thing With Extra Spaces', false], ['Thing with extra spaces', 'Thing With Extra Spaces', true], ['Observations of isolated pulsars and disk-fed X-ray binaries.', 'Observations of Isolated Pulsars and Disk-Fed X-Ray Binaries.', false] ]; function APATitle($title, $keepMultipleSpaces = false, $blackList = []) { if (!is_string($title)) { return false; } $blackList = $blackList ? array_map('strtolower', (array)$blackList) : ['a', 'an', 'and', 'at', 'but', 'by', 'for', 'in', 'nor', 'of', 'on', 'or', 'so', 'the', 'to', 'up', 'yet']; if (!$keepMultipleSpaces) { $title = preg_replace('~\s+~', ' ', $title); } return preg_replace_callback( '~(?!^)\b(?:' . implode('|', $blackList) . ')\b(?!$)(*SKIP)(*FAIL)|\b[a-z]+\b~', function ($m) { return ucfirst($m[0]); }, strtolower($title) ); } foreach ($tests as [$input, $expectedOutput, $keepMultipleSpaces]) { $output = APATitle($input, $keepMultipleSpaces); echo ($output === $expectedOutput ? 'SUCCESS' : 'FAILURE') . ":\t\"{$input}\" became \"{$output}\"\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.3.60.0070.00718.40
8.3.50.0100.01318.45
8.3.40.0050.01419.00
8.3.30.0110.00319.39
8.3.20.0000.00721.89
8.3.10.0040.00420.30
8.3.00.0050.00321.90
8.2.180.0040.01125.92
8.2.170.0090.00622.96
8.2.160.0100.00722.15
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0090.00026.16
8.2.120.0040.00426.16
8.2.110.0040.00422.23
8.2.100.0080.00318.03
8.2.90.0080.00017.86
8.2.80.0090.00019.28
8.2.70.0080.00017.75
8.2.60.0030.00517.73
8.2.50.0000.00818.05
8.2.40.0040.00420.14
8.2.30.0000.00718.21
8.2.20.0040.00418.23
8.2.10.0070.00019.38
8.2.00.0080.00019.50
8.1.280.0100.01025.92
8.1.270.0080.00021.05
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0060.00322.32
8.1.230.0110.00021.04
8.1.220.0030.00617.91
8.1.210.0090.00019.10
8.1.200.0000.01017.60
8.1.190.0050.00317.60
8.1.180.0060.00318.10
8.1.170.0040.00417.62
8.1.160.0080.00018.96
8.1.150.0000.00719.02
8.1.140.0000.00719.04
8.1.130.0050.00220.20
8.1.120.0070.00017.56
8.1.110.0080.00017.66
8.1.100.0040.00417.54
8.1.90.0040.00417.66
8.1.80.0040.00417.59
8.1.70.0050.00217.51
8.1.60.0040.00417.78
8.1.50.0000.00817.75
8.1.40.0040.00417.65
8.1.30.0080.00017.82
8.1.20.0060.00317.80
8.1.10.0040.00417.69
8.1.00.0080.00017.72
8.0.300.0030.00520.20
8.0.290.0070.00417.00
8.0.280.0040.00418.50
8.0.270.0000.00718.08
8.0.260.0000.00618.41
8.0.250.0050.00217.11
8.0.240.0000.00717.17
8.0.230.0000.00717.08
8.0.220.0050.00217.07
8.0.210.0070.00017.14
8.0.200.0070.00317.12
8.0.190.0050.00217.05
8.0.180.0080.00017.04
8.0.170.0040.00417.15
8.0.160.0000.00817.13
8.0.150.0060.00316.91
8.0.140.0070.00017.11
8.0.130.0030.00313.48
8.0.120.0080.00016.94
8.0.110.0000.00717.12
8.0.100.0040.00417.07
8.0.90.0090.00017.11
8.0.80.0060.01017.01
8.0.70.0070.00016.86
8.0.60.0000.00816.95
8.0.50.0070.00017.20
8.0.30.0080.01717.13
8.0.20.0140.00617.16
8.0.10.0050.00317.09
8.0.00.0140.00616.73
7.4.330.0050.00015.55
7.4.320.0070.00016.84
7.4.300.0030.00316.90
7.4.290.0000.00716.71
7.4.280.0080.00016.84
7.4.270.0030.00516.68
7.4.260.0030.00313.50
7.4.250.0040.00416.82
7.4.240.0000.00716.77
7.4.230.0030.00316.88
7.4.220.0050.00216.69
7.4.210.0090.01016.77
7.4.200.0030.00616.97
7.4.130.0110.00716.75
7.4.120.0120.00616.61
7.4.110.0070.01116.67
7.4.100.0090.01516.80
7.4.90.0070.01016.80
7.4.80.0040.01319.39
7.4.70.0080.00816.67
7.4.60.0060.01116.64
7.4.50.0070.01116.74
7.4.40.0070.01416.30
7.4.30.0150.00716.52
7.4.20.0140.00916.31
7.4.10.0000.02316.70
7.4.00.0140.00716.79
7.3.330.0040.00416.57
7.3.320.0060.00013.35
7.3.310.0040.00416.59
7.3.300.0000.00716.56
7.3.290.0060.01016.52
7.3.260.0120.01216.65
7.3.230.0170.00016.64
7.3.210.0100.01016.52
7.3.200.0110.00816.49
7.3.190.0060.01216.88
7.3.180.0080.01116.78
7.3.170.0170.00716.64
7.3.160.0150.00616.41
7.3.150.0100.01216.50
7.3.140.0040.01716.53
7.3.130.0120.00916.70
7.3.120.0060.01516.45
7.3.110.0130.01016.48
7.3.100.0090.01516.48
7.3.90.0150.00616.52
7.3.80.0110.01116.52
7.3.70.0090.00916.50
7.3.60.0070.01516.57
7.3.50.0150.00916.77
7.3.40.0110.00916.56
7.3.30.0000.01816.57
7.3.20.0100.01016.56
7.3.10.0240.00716.66
7.3.00.0090.01616.57
7.2.330.0110.00716.96
7.2.320.0090.00716.82
7.2.310.0090.01217.05
7.2.300.0100.01316.75
7.2.290.0090.00916.68
7.2.280.0180.00616.91
7.2.270.0140.00516.62
7.2.260.0200.00316.84
7.2.250.0090.01416.67
7.2.240.0130.01016.70
7.2.230.0130.01016.59
7.2.220.0100.01516.87
7.2.210.0120.00916.99
7.2.200.0130.00616.83
7.2.190.0120.01216.92
7.2.180.0130.01116.71
7.2.170.0080.01816.79
7.2.160.0110.01116.82
7.2.150.0140.01116.93
7.2.140.0030.02016.66
7.2.130.0070.01216.79
7.2.120.0100.01316.79
7.2.110.0110.01016.77
7.2.100.0150.00616.81
7.2.90.0040.00416.85
7.2.80.0090.01616.70
7.2.70.0070.01816.84
7.2.60.0170.00316.93
7.2.50.0150.00916.67
7.2.40.0100.01016.83
7.2.30.0140.01017.00
7.2.20.0110.01316.80
7.2.10.0040.01916.75
7.2.00.0080.01116.80

preferences:
63.34 ms | 401 KiB | 5 Q