3v4l.org

run code in 300+ PHP versions simultaneously
<?php // phpcs:ignoreFile $separator = '-'; $subjects = [ 'SomeCamelCase' => 'Some-Camel-Case', 'Some12With5Numbers' => 'Some-12-With-5-Numbers', 'SomePDFInText' => 'Some-PDF-In-Text', '123LeadingNumbers' => '123-Leading-Numbers', 'ItIs2016' => 'It-Is-2016', 'What-If' => 'What-If', 'ASingleLetterB' => 'A-Single-Letter-B', 'some_snake_case' => 'some_snake_case', 'Title_Snake_Case' => 'Title-_-Snake-_-Case', 'lower-with-dash' => 'lowerwithdash', 'FFS!' => 'FFS-!', 'WithA😃' => 'With-A-😃', 'PDF123' => 'PDF-123', 'EmojiInThe🤞Middle' => 'Emoji-In-The-🤞-Middle', '12345' => '12345', '123A' => '123-A', 'A123' => 'A-123', 'War&Peace' => 'War-&-Peace', 'lowerThenTitleCase' => 'lower-Then-Title-Case', '123lower' => '123-lower', 'lower123' => 'lower-123', 'ItIsÜber' => 'It-Is-Über', 'SømeThing' => 'Søme-Thing', ]; foreach ($subjects as $subject => $expect) { $pattern = <<<REGEXP / ( (?:\p{Lu}\p{Ll}+) # Upper followed by lower | (?:\p{Lu}+(?!\p{Ll})) # Upper not followed by lower | (?:\p{N}+) # Runs of numbers ) /ux REGEXP; $result = implode( $separator, preg_split( $pattern, str_replace($separator, '', $subject), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY, ), ); echo $result === $expect ? '✅' : '❌', ' ', $result, PHP_EOL; }

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.10.0100.00719.57
8.3.140.0160.00319.10
8.3.130.0060.00318.61
8.3.120.0110.00016.92
8.3.110.0110.00017.16
8.3.100.0110.00016.86
8.3.90.0100.00316.97
8.3.80.0130.00316.66
8.3.70.0140.00316.49
8.3.60.0190.00016.27
8.3.50.0090.00616.29
8.3.40.0180.00017.40
8.3.30.0100.00717.08
8.3.20.0080.00417.34
8.3.10.0120.00617.57
8.3.00.0040.00719.23
8.2.260.0040.01416.77
8.2.250.0040.01216.51
8.2.240.0070.00718.54
8.2.230.0150.00016.16
8.2.220.0080.00816.33
8.2.210.0160.00016.50
8.2.200.0100.00516.34
8.2.190.0040.00918.09
8.2.180.0040.01116.19
8.2.170.0150.00217.57
8.2.160.0160.00017.73
8.2.150.0150.00317.65
8.2.140.0200.00017.01
8.2.130.0150.00317.00
8.2.120.0180.00017.54
8.2.110.0140.00317.45
8.2.100.0140.00317.45
8.2.90.0100.00717.16
8.2.80.0090.00617.29
8.2.70.0160.00017.39
8.2.60.0120.00217.60
8.2.50.0100.00317.34
8.2.40.0180.00017.51
8.2.30.0140.00217.51
8.2.20.0080.00817.46
8.2.10.0140.00316.94
8.2.00.0080.00817.37
8.1.310.0100.00716.54
8.1.300.0100.00516.41
8.1.290.0060.00916.17
8.1.280.0100.00316.05
8.1.270.0080.00817.57
8.1.260.0140.00517.01
8.1.250.0130.00317.22
8.1.240.0130.00016.89
8.1.230.0150.00017.04
8.1.220.0080.00817.07
8.1.210.0000.01417.03
8.1.200.0110.00417.14
8.1.190.0090.00517.01
8.1.180.0100.00516.92
8.1.170.0160.00017.07
8.1.160.0110.00418.88
8.1.150.0110.00317.28
8.1.140.0150.00017.41
8.1.130.0060.00617.16
8.1.120.0050.01017.13
8.1.110.0050.00917.07
8.1.100.0130.00016.94
8.1.90.0110.00417.30
8.1.80.0050.01016.67
8.1.70.0090.00517.32
8.1.60.0070.01118.96
8.1.50.0080.00817.44
8.1.40.0140.00217.33
8.1.30.0160.00017.49
8.1.20.0050.00917.29
8.1.10.0080.00817.45
8.1.00.0130.00518.99

preferences:
44.73 ms | 403 KiB | 5 Q