3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Spintax { public static function Parse($text) { return self::Process($text); } private static function Process($text) { $pattern = '/\{(((?>[^\{\}]+)|(?R))*)\}/x'; return preg_replace_callback($pattern, ['Spintax', 'Replace'], $text); } private static function Replace($text) { $text = self::Process($text[1]); $parts = explode('|', $text); return $parts[array_rand($parts)]; } } $spintax = "{The|The actual|The particular|Your|This} breakthrough treatment {works by|functions|functions by|operates by|sticks to} oxygenating {the|the actual|the particular|your|this} blood {through an|with an|via an|using an|with the} injection {that can|that may|that will|which could|that could} hold {someone|somebody|an individual|a person|another person} alive {for up to|for approximately|for|for about|for as much as} 30 minutes {even if|even though|even when|regardless of whether|whether or not} they {are unable to|cannot|can't|can't seem to|are not able to} breath {at|from|with|in|on} everything {and could|and may|and might|and can|and may even} save {thousands of|a large number of|1000s of|a huge number of|many} lives."; for($n = 0; $n < 20; $n++){ echo Spintax::Parse($spintax) . "\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.0.20.0060.01317.66
8.0.10.0330.00317.40
8.0.00.0210.01517.40
7.4.150.0060.01217.40
7.4.140.0220.01117.40
7.4.130.0350.00317.40
7.4.120.0290.00417.40
7.4.110.0170.01717.40
7.4.100.0210.01317.40
7.4.90.0290.00617.40
7.4.80.0210.01317.40
7.4.70.0250.00617.40
7.4.60.0170.01217.40
7.4.50.0200.01317.40
7.4.40.0220.00917.40
7.4.30.0210.01317.40
7.4.20.0210.01117.40
7.4.10.0270.00417.40
7.4.00.0240.00517.40
7.3.270.0160.00317.40
7.3.260.0220.01217.40
7.3.250.0250.00617.40
7.3.240.0340.00017.40
7.3.230.0180.01517.40
7.3.220.0250.00917.40
7.3.210.0290.00417.40
7.3.200.0230.01217.40
7.3.190.0290.00417.40
7.3.180.0220.01117.40
7.3.170.0190.01417.40
7.3.160.0280.00617.40
7.3.150.0180.01517.40
7.3.140.0230.01117.40
7.3.130.0260.00717.40
7.3.120.0350.00017.40
7.3.110.0220.00917.40
7.3.100.0130.01717.40
7.3.90.0210.01117.40
7.3.80.0340.00017.40
7.3.70.0210.01417.40
7.3.60.0240.01017.40
7.3.50.0280.00617.40
7.3.40.0200.01217.40
7.3.30.0230.01017.40
7.3.20.0250.00917.40
7.3.10.0300.00317.40
7.3.00.0290.01417.40
7.2.340.0260.00617.40
7.2.330.0310.01217.40
7.2.320.0310.01017.40
7.2.310.0150.01617.40
7.2.300.0170.01717.40
7.2.290.0270.00717.40
7.2.280.0270.00917.40
7.2.270.0250.00717.40
7.2.260.0260.00417.40
7.2.250.0170.01417.40
7.2.240.0180.01417.40
7.2.230.0210.01117.40
7.2.220.0180.01317.40
7.2.210.0240.00817.40
7.2.200.0230.01317.40
7.2.190.0340.00717.40
7.2.180.0200.01217.40
7.2.170.0250.01017.40
7.2.160.0230.00817.40
7.2.150.0330.00617.40
7.2.140.0270.00617.40
7.2.130.0210.01417.40
7.2.120.0230.01217.40
7.2.110.2620.01716.13
7.2.100.2120.01416.04
7.2.90.1960.00616.24
7.2.80.1670.00816.20
7.2.70.1870.00516.40
7.2.60.2680.00516.37
7.2.50.0350.01016.35
7.2.40.0550.01016.34
7.2.30.2360.00916.30
7.2.20.2100.01316.44
7.2.10.2160.00916.07
7.2.00.1980.00516.38
7.1.330.0200.01017.40
7.1.320.0180.01317.40
7.1.310.0370.00817.40
7.1.300.0190.01217.40
7.1.290.0610.00417.40
7.1.280.0230.00917.40
7.1.270.0240.01017.40
7.1.260.0250.00917.40
7.1.250.0260.01217.40
7.1.240.0630.01017.40
7.1.230.2080.00915.86
7.1.220.2470.01015.75
7.1.210.2260.01015.71
7.1.200.1670.01115.74
7.1.190.1240.00815.67
7.1.180.2490.00715.72
7.1.170.0220.00715.58
7.1.160.2480.01015.80
7.1.150.2280.00915.69
7.1.140.2130.00915.70
7.1.130.2080.00815.64
7.1.120.2330.01015.62
7.1.110.1870.00915.69
7.1.100.2290.00515.72
7.1.90.2030.01415.69
7.1.80.2080.00915.68
7.1.70.2220.01315.67
7.1.60.0790.01624.88
7.1.50.0360.01024.71
7.1.40.2850.01024.74
7.1.30.3650.01024.85
7.1.20.2110.01724.81
7.1.10.3070.00515.82
7.1.00.2180.00915.71
7.0.330.0190.01617.40
7.0.320.0220.00817.40
7.0.310.0190.01217.40
7.0.300.0280.00817.40
7.0.290.0210.00917.40
7.0.280.0250.00417.40
7.0.270.0280.00917.40
7.0.260.0210.00717.40
7.0.250.0150.01517.40
7.0.240.0250.00517.40
7.0.230.0130.01617.40
7.0.220.0230.01017.40
7.0.210.0220.00817.40
7.0.200.0150.01517.40
7.0.190.0600.01717.40
7.0.180.0270.00917.40
7.0.170.0260.00617.40
7.0.160.0190.00917.40
7.0.150.0200.01217.40
7.0.140.0150.01517.40
7.0.130.0180.01217.40
7.0.120.0260.00417.40
7.0.110.0230.00417.40
7.0.100.0160.01317.40
7.0.90.0280.00817.40
7.0.80.0230.00617.40
7.0.70.0250.00717.40
7.0.60.0170.01217.40
7.0.50.0260.00517.40
7.0.40.0310.01017.40
7.0.30.0230.00617.40
7.0.20.0270.01417.40
7.0.10.0240.00617.40
7.0.00.0250.00417.40
5.6.400.0170.01717.40
5.6.390.0230.01217.40
5.6.380.0180.00915.88
5.6.370.0300.01217.40
5.6.360.0240.01417.40
5.6.350.0200.01017.40
5.6.340.0170.01417.40
5.6.330.0210.01817.40
5.6.320.0200.01417.40
5.6.310.0230.00917.40
5.6.300.0290.00617.40
5.6.290.0230.01217.40
5.6.280.0180.01417.40
5.6.270.0220.01417.40
5.6.260.0220.00817.40
5.6.250.0210.01217.40
5.6.240.0170.01417.40
5.6.230.0220.00917.40
5.6.220.0210.01517.40
5.6.210.0260.00817.40
5.6.200.0250.01017.40
5.6.190.0190.01417.40
5.6.180.0180.01517.40
5.6.170.0150.01817.40
5.6.160.0260.00717.40
5.6.150.0230.01217.40
5.6.140.0230.01017.40
5.6.130.0190.01917.40
5.6.120.0080.02517.40
5.6.110.0210.01017.40
5.6.100.0220.01017.40
5.6.90.0160.01617.40
5.6.80.0240.00817.40
5.6.70.0190.01117.40
5.6.60.0140.01717.40
5.6.50.0300.01417.40
5.6.40.0200.01217.40
5.6.30.0200.01017.40
5.6.20.0140.01917.40
5.6.10.0220.01617.40
5.6.00.0160.01917.40

preferences:
41.85 ms | 400 KiB | 5 Q