3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'IF(1>10, "Large", "Medium") IF(1>10, IF(44>20, "Large", "Medium"), "Small") IF(1>10, IF(44>20, "Large", IF(4<5, "Tiny", "Medium")), "Small") IF(A1>10, IF(A1>20, "Large", IF(A1<5, "Tiny", "Medium")), "Small")'; $pattern =<<<'REGEX' ~ # subpatterns (?<string> " [^"\\]*+ (?s: \\. [^"\\]* )*+ " ){0} (?<nparens> \( [^"()]*+ (?: \g<string> [^"()]* | \g<nparens> [^"()]* )*+ \) ){0} (?<other> [^"()\s,] (?: [^"(),]* [^"()\s,])? ){0} (?<part> (?: \g<string> | \g<nparens> | \g<other> )* ){0} # main pattern IF\( \s* (\g<part>) \s* , \s* (\g<part>) \s*, \s* (\g<part>) \s* \) ~x REGEX; //$replacement = '($7) ? ($8) : ($9)'; $replacement = '($5) ? ($6) : ($7)'; do { $str = preg_replace($pattern, $replacement, $str, -1, $count); } while ($count); echo $str;

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.00917.86
8.4.120.0110.00920.38
8.4.110.0120.00718.82
8.4.100.0060.00318.00
8.4.90.0100.01217.84
8.4.80.0120.00718.13
8.4.70.0040.00519.82
8.4.60.0100.01017.89
8.4.50.0260.01017.88
8.4.40.0050.00418.05
8.3.250.0100.00918.89
8.3.240.0100.01016.70
8.3.230.0130.00716.51
8.3.220.0050.00416.92
8.3.210.0050.00316.73
8.3.200.0120.00716.58
8.3.190.0070.01216.54
8.3.180.0140.00616.63
8.3.170.0110.00816.78
8.3.50.0070.01216.64
8.2.290.0120.00720.33
8.2.280.0080.00216.67

preferences:
27.47 ms | 403 KiB | 5 Q