3v4l.org

run code in 300+ PHP versions simultaneously
<?php function toArray($s){ $operators = array('+','-','*','/','%','(',')'); $finalArr = []; $curStr = ''; foreach (str_split($s) as $char) { if (in_array($char, $operators)) { //Alright, we have an operator. Append the entire number $finalArr[] = $curStr; //And also the operator $finalArr[] = $char; //Reset the current string back to empty $curStr = ''; } else { //Not an operator? Just keep appending the current number $curStr .= $char; } } //Add final leftover string if ($curStr !== '') { //Sanity check here (This shouldn't ever be empty, as you wouldn't end with an operator) $finalArr[] = $curStr; } //Return return $finalArr; } $string = '6+4*4+100+444*6*13*14'; $arr = toArray($string); print_r($arr);

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.5.10.0110.00618.52
8.5.00.0130.01019.97
8.4.160.0110.01023.92
8.4.150.0020.00014.05
8.4.140.0130.00917.56
8.4.130.0100.01117.73
8.4.120.0090.01120.41
8.4.110.0060.01018.80
8.4.100.0080.00917.87
8.4.90.0110.01020.38
8.4.80.0040.00419.49
8.4.70.0130.00717.58
8.4.60.0130.00820.52
8.4.50.0100.01019.57
8.4.40.0060.01017.69
8.4.30.0130.00617.80
8.4.20.0070.00417.52
8.4.10.0030.00619.39
8.3.290.0120.00818.32
8.3.280.0130.01018.56
8.3.270.0120.01116.74
8.3.260.0130.00716.59
8.3.250.0050.00318.91
8.3.240.0050.00316.92
8.3.230.0120.00716.50
8.3.220.0130.00617.51
8.3.210.0090.00816.86
8.3.200.0020.00616.55
8.3.190.0090.00917.20
8.3.180.0130.00516.55
8.3.170.0080.00019.04
8.3.160.0040.01516.58
8.3.150.0120.00619.15
8.3.140.0120.00916.62
8.3.130.0080.00818.31
8.3.120.0060.01320.63
8.3.110.0130.00616.64
8.3.100.0110.00420.47
8.3.90.0000.00918.18
8.3.80.0060.00318.56
8.3.70.0040.01116.63
8.3.60.0090.00918.56
8.3.50.0100.01018.29
8.3.40.0120.00318.85
8.3.30.0070.00718.84
8.3.20.0050.00220.16
8.3.10.0040.00421.89
8.3.00.0030.00519.26
8.2.300.0110.01018.13
8.2.290.0100.00820.14
8.2.280.0050.00318.62
8.2.270.0000.00817.26
8.2.260.0090.00918.79
8.2.250.0110.00418.15
8.2.240.0060.00317.29
8.2.230.0060.00320.94
8.2.220.0080.00037.54
8.2.210.0000.00926.77
8.2.200.0030.00616.88
8.2.190.0040.01516.58
8.2.180.0110.00716.50
8.2.170.0110.00722.96
8.2.160.0090.00920.43
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0000.00720.56
8.2.120.0060.00326.35
8.2.110.0040.00421.06
8.2.100.0040.00718.03
8.2.90.0000.00818.25
8.2.80.0040.00418.22
8.2.70.0080.00017.63
8.2.60.0000.00817.63
8.2.50.0000.00917.63
8.2.40.0020.00520.53
8.2.30.0030.00519.36
8.2.20.0080.00018.13
8.2.10.0050.00318.09
8.2.00.0030.00518.37
8.1.340.0160.00417.59
8.1.330.0040.00322.13
8.1.320.0120.00616.16
8.1.310.0070.01016.55
8.1.300.0120.00319.90
8.1.290.0090.00018.88
8.1.280.0040.01125.92
8.1.270.0070.00020.18
8.1.260.0000.00926.35
8.1.250.0050.00328.09
8.1.240.0030.00622.54
8.1.230.0040.00720.89
8.1.220.0040.00417.77
8.1.210.0040.00418.77
8.1.200.0060.00317.35
8.1.190.0030.00717.23
8.1.180.0040.00418.10
8.1.170.0030.00518.65
8.1.160.0070.00018.94
8.1.150.0000.00718.84
8.1.140.0000.00717.59
8.1.130.0000.00717.57
8.1.120.0000.00717.37
8.1.110.0040.00417.48
8.1.100.0080.00017.49
8.1.90.0040.00417.37
8.1.80.0000.00717.36
8.1.70.0000.00717.49
8.1.60.0060.00317.54
8.1.50.0030.00517.42
8.1.40.0060.00317.43
8.1.30.0030.01017.61
8.1.20.0020.00517.59
8.1.10.0030.00617.56
8.1.00.0000.00817.37
8.0.300.0000.00720.04
8.0.290.0000.00816.63
8.0.280.0030.00318.46
8.0.270.0030.00316.81
8.0.260.0060.00016.77
8.0.250.0000.00717.01
8.0.240.0060.00316.97
8.0.230.0030.00316.92
8.0.220.0030.00316.86
8.0.210.0030.00316.90
8.0.200.0030.00316.90
8.0.190.0050.00316.98
8.0.180.0040.00416.88
8.0.170.0080.00016.84
8.0.160.0000.00816.88
8.0.150.0000.01116.75
8.0.140.0040.00416.81
8.0.130.0060.00013.37
8.0.120.0040.00416.79
8.0.110.0040.00416.86
8.0.100.0000.00716.86
8.0.90.0000.00816.84
8.0.80.0040.01216.93
8.0.70.0000.00716.88
8.0.60.0000.00816.80
8.0.50.0050.00316.84
8.0.30.0090.00816.86
8.0.20.0110.00917.40
8.0.10.0040.00416.89
8.0.00.0050.01216.69
7.4.330.0000.00615.55
7.4.320.0060.00016.46
7.4.300.0060.00016.41
7.4.290.0000.00716.45
7.4.280.0050.00316.50
7.4.270.0000.00716.44
7.4.260.0000.00716.53
7.4.250.0030.00316.39
7.4.240.0000.00716.42
7.4.230.0040.00416.62
7.4.220.0000.00716.35
7.4.210.0040.01116.48
7.4.200.0030.00316.40
7.4.160.0070.01416.74
7.4.150.0150.00317.40
7.4.140.0120.00817.86
7.4.130.0100.00716.68
7.4.120.0110.00816.50
7.4.110.0100.00716.63
7.4.100.0060.00916.52
7.4.90.0050.01216.42
7.4.80.0140.01119.39
7.4.70.0140.00316.41
7.4.60.0130.00316.49
7.4.50.0130.00316.51
7.4.40.0060.01616.55
7.4.10.0090.00914.59
7.4.00.0080.00814.89
7.3.330.0000.00613.39
7.3.320.0030.00313.38
7.3.310.0000.00716.40
7.3.300.0020.00516.27
7.3.290.0100.00616.39
7.3.280.0110.00516.36
7.3.270.0060.01217.40
7.3.260.0090.00916.48
7.3.250.0090.01016.45
7.3.240.0090.00916.40
7.3.230.0030.01316.45
7.3.210.0140.00316.64
7.3.200.0100.01316.57
7.3.190.0090.00916.39
7.3.180.0040.01216.38
7.3.170.0120.00316.58
7.3.160.0120.00316.51
7.3.130.0100.01015.03
7.3.120.0060.00614.60
7.3.110.0070.01015.09
7.3.100.0030.00914.54
7.3.90.0070.00314.80
7.3.80.0030.00914.58
7.3.70.0100.00315.01
7.3.60.0050.00514.96
7.3.50.0100.00714.93
7.3.40.0000.01514.84
7.3.30.0120.00314.84
7.3.20.0070.00716.73
7.3.10.0070.00716.56
7.3.00.0120.00016.52
7.2.330.0070.01016.54
7.2.320.0060.01216.77
7.2.310.0100.01016.84
7.2.300.0100.00716.44
7.2.290.0090.01216.61
7.2.260.0100.01015.09
7.2.250.0040.01415.09
7.2.240.0030.01314.84
7.2.230.0130.00315.02
7.2.220.0090.00615.23
7.2.210.0000.01315.18
7.2.200.0100.00315.02
7.2.190.0100.00315.19
7.2.180.0040.01115.03
7.2.170.0090.00615.20
7.2.160.0030.01214.79
7.2.150.0060.00916.74
7.2.140.0110.00316.96
7.2.130.0080.00617.02
7.2.120.0120.00317.14
7.2.110.0070.00716.74
7.2.100.0000.00916.84
7.2.90.0080.00816.80
7.2.80.0070.01416.81
7.2.70.0060.00916.88
7.2.60.0020.00816.94
7.2.50.0120.00317.02
7.2.40.0100.00717.11
7.2.30.0030.00917.09
7.2.20.0040.00716.78
7.2.10.0210.00817.62
7.2.00.0170.00517.56
7.1.330.0000.01415.89
7.1.320.0070.00315.89
7.1.310.0000.01315.59
7.1.300.0030.00815.73
7.1.290.0100.00315.91
7.1.280.0030.00615.77
7.1.270.0080.00015.82
7.1.260.0040.00716.04
7.1.250.0040.00715.54
7.1.240.0060.00315.94
7.1.230.0080.00415.77
7.1.220.0030.00715.95
7.1.210.0100.01016.02
7.1.200.0070.00815.77
7.1.190.0050.00515.81
7.1.180.0060.00915.46
7.1.170.0070.00615.95
7.1.160.0090.00915.90
7.1.150.0060.00615.56
7.1.140.0040.01115.96
7.1.130.0160.00616.47
7.1.120.0140.01216.30
7.1.110.0170.00716.12
7.1.100.0150.01015.97
7.1.90.0140.01016.01
7.1.80.0110.01115.96
7.1.70.0160.00815.61
7.1.60.0200.00924.47
7.1.50.0190.01324.44
7.1.40.0430.01024.22
7.1.30.0270.00824.10
7.1.20.0270.00524.26
7.1.10.0140.00815.22
7.1.00.0160.00715.31
7.0.330.0030.00715.50
7.0.320.0030.00715.25
7.0.310.0030.01015.45
7.0.300.0120.00015.54
7.0.290.0040.00415.33
7.0.280.0040.00415.27
7.0.270.0000.01115.35
7.0.260.0100.00715.37
7.0.250.0110.00715.54
7.0.240.0170.00015.57
7.0.230.0040.01215.68
7.0.220.0100.00715.41
7.0.210.0120.00615.18
7.0.200.0100.00715.61
7.0.190.0100.01015.47
7.0.180.0070.00715.36
7.0.170.0090.00315.39
7.0.160.0070.00715.58
7.0.150.0080.00615.62
7.0.140.0080.00815.31
7.0.130.0100.00315.62
7.0.120.0060.00615.42
7.0.110.0110.00315.32
7.0.100.0000.00915.56
7.0.90.0040.00415.24
7.0.80.0030.00615.55
7.0.70.0060.00715.51
7.0.60.0100.00315.34
7.0.50.0110.00415.50
7.0.40.0040.01413.50
7.0.30.0080.00513.63
7.0.20.0050.00513.45
7.0.10.0000.01613.27
7.0.00.0030.00913.55
5.6.400.0030.00814.58
5.6.390.0070.00314.39
5.6.380.0150.00014.66
5.6.370.0000.01214.70
5.6.360.0110.01114.37
5.6.350.0000.01514.61
5.6.340.0030.01414.32
5.6.330.0070.01113.99
5.6.320.0060.00614.31
5.6.310.0060.00914.30
5.6.300.0110.00314.29
5.6.290.0090.00614.61
5.6.280.0060.00314.64
5.6.270.0060.00614.23
5.6.260.0070.01014.71
5.6.250.0100.00714.39
5.6.240.0030.01014.59
5.6.230.0070.01114.27
5.6.220.0030.01014.54
5.6.210.0060.00914.55
5.6.200.0090.00614.54
5.6.190.0060.00914.44
5.6.180.0030.01014.36
5.6.170.0060.01014.56
5.6.160.0040.00814.38
5.6.150.0030.00914.42
5.6.140.0070.00314.56
5.6.130.0040.01114.39
5.6.120.0040.01414.54
5.6.110.0000.01614.42
5.6.100.0000.01414.39
5.6.90.0140.00314.53
5.6.80.0070.00714.46
5.6.70.0040.01114.46
5.6.60.0070.00714.07
5.6.50.0030.01014.39
5.6.40.0070.00714.61
5.6.30.0060.00914.22
5.6.20.0070.00714.66
5.6.10.0030.00614.28
5.6.00.0040.00414.54

preferences:
31.01 ms | 403 KiB | 5 Q