3v4l.org

run code in 300+ PHP versions simultaneously
<?php $desc = "GLOVE EXAM BEST TCH ALOE LTX MED 100/BX 10BX/CS"; $uom = "CS"; $keywords = explode(" ", $desc); $pkgstring = ""; $result = []; foreach ($keywords as $key => $keyword){ $firstchar = substr($keyword, 0, 1); if (is_numeric($firstchar)) { $pkgstring .= $keyword.","; } } $pkgstring = substr($pkgstring, 0, -1); $result['pkgstring'] = $pkgstring; $str_ele = explode(",", $pkgstring); $qty_uom = 1; $new_arr[0] = ""; $pos = 1; if (stripos($pkgstring, $uom) !== false){ // sort each element in the best order to execute the rest of the function foreach ($str_ele as $key => $element) { if (stripos($element, '/') !== false) { $x = stripos($element, '/'); $chk = substr($element, $x-1, 1); if (is_numeric($chk)) { $new_arr[0] = $element; } else { $new_arr[$pos] = $element; $pos++; } } } // do the math to get the qty/uom foreach ($new_arr as $key => $str) { echo $str."\n\n"; if (stripos($str, '/'.$uom) !== false) { $size = preg_replace('/[^0-9]/', '', $str); $qty_uom *= $size; break; } else { $size = preg_replace('/[^0-9]/', '', $str); $qty_uom *= $size; } } } $result['qty_uom'] = $qty_uom; print_r($result);

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.70.0110.00818.59
8.3.60.0120.00318.43
8.3.50.0100.01016.80
8.3.40.0110.00419.03
8.3.30.0120.00319.10
8.3.20.0050.00319.28
8.3.10.0080.00023.66
8.3.00.0080.00023.84
8.2.190.0090.00616.63
8.2.180.0190.00318.41
8.2.170.0090.00622.96
8.2.160.0070.00719.39
8.2.150.0040.00424.18
8.2.140.0040.00424.66
8.2.130.0000.00820.53
8.2.120.0040.00426.35
8.2.110.0000.01121.16
8.2.100.0060.00618.22
8.2.90.0000.00818.03
8.2.80.0030.00618.03
8.2.70.0040.00417.90
8.2.60.0060.00618.22
8.2.50.0030.00518.10
8.2.40.0030.00519.36
8.2.30.0040.00419.51
8.2.20.0000.00718.23
8.2.10.0030.00519.36
8.2.00.0030.00319.54
8.1.280.0110.01125.92
8.1.270.0080.00020.35
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0170.00721.99
8.1.230.0040.00822.69
8.1.220.0000.00917.74
8.1.210.0050.00318.77
8.1.200.0000.00917.60
8.1.190.0000.00917.60
8.1.180.0040.00418.10
8.1.170.0040.00419.05
8.1.160.0040.00418.90
8.1.150.0000.00718.82
8.1.140.0040.00419.51
8.1.130.0000.00719.07
8.1.120.0000.00817.54
8.1.110.0040.00417.63
8.1.100.0000.00817.65
8.1.90.0030.00617.68
8.1.80.0050.00217.68
8.1.70.0000.00717.63
8.1.60.0000.00817.73
8.1.50.0000.00817.54
8.1.40.0040.00417.71
8.1.30.0090.00417.75
8.1.20.0000.00717.86
8.1.10.0050.00517.75
8.1.00.0030.00617.58
8.0.300.0040.00419.76
8.0.290.0000.00917.00
8.0.280.0000.00718.42
8.0.270.0000.00717.25
8.0.260.0000.00717.23
8.0.250.0070.00017.14
8.0.240.0050.00317.12
8.0.230.0000.00717.11
8.0.220.0040.00416.98
8.0.210.0000.00717.13
8.0.200.0030.00317.01
8.0.190.0040.00417.08
8.0.180.0040.00417.05
8.0.170.0030.00617.10
8.0.160.0000.00717.07
8.0.150.0080.00016.96
8.0.140.0000.00716.96
8.0.130.0000.00713.54
8.0.120.0040.00416.99
8.0.110.0050.00317.10
8.0.100.0040.00416.93
8.0.90.0000.00817.10
8.0.80.0080.00816.97
8.0.70.0050.00217.12
8.0.60.0040.00417.12
8.0.50.0050.00217.12
8.0.30.0100.00917.42
8.0.20.0130.00817.40
8.0.10.0040.00417.25
8.0.00.0170.00316.92
7.4.330.0050.00015.55
7.4.320.0000.00816.85
7.4.300.0000.00616.83
7.4.290.0030.00316.69
7.4.280.0040.00416.85
7.4.270.0000.00716.77
7.4.260.0030.00316.72
7.4.250.0030.00316.73
7.4.240.0000.00716.71
7.4.230.0070.00016.82
7.4.220.0050.00316.80
7.4.210.0080.00916.86
7.4.200.0000.00716.88
7.4.160.0090.00716.72
7.4.140.0080.01117.86
7.4.130.0090.00916.63
7.4.120.0090.01116.78
7.4.110.0040.01316.86
7.4.100.0130.00816.55
7.4.90.0140.00416.60
7.4.80.0090.00919.39
7.4.70.0130.00716.67
7.4.60.0040.01216.41
7.4.50.0080.00616.49
7.4.40.0030.01316.52
7.4.00.0080.01115.18
7.3.330.0000.00513.47
7.3.320.0030.00313.41
7.3.310.0080.00016.49
7.3.300.0030.00316.46
7.3.290.0000.00716.41
7.3.280.0060.00916.52
7.3.260.0080.00916.63
7.3.240.0130.00816.67
7.3.230.0070.01116.73
7.3.210.0100.01316.46
7.3.200.0110.00616.87
7.3.190.0110.01116.45
7.3.180.0130.00316.79
7.3.170.0070.01016.50
7.3.160.0110.01116.60
7.3.120.0070.01115.06
7.3.110.0110.00614.80
7.3.100.0070.00714.98
7.3.90.0070.01514.75
7.3.80.0060.00614.89
7.3.70.0030.01014.96
7.3.60.0090.00315.05
7.3.50.0070.00715.16
7.3.40.0120.00014.75
7.3.30.0070.00714.68
7.3.20.0030.01316.93
7.3.10.0060.00616.88
7.3.00.0000.01017.00
7.2.330.0090.01616.79
7.2.320.0030.01516.85
7.2.310.0130.01016.67
7.2.300.0080.01016.84
7.2.290.0140.00416.70
7.2.250.0060.01315.37
7.2.240.0000.02015.24
7.2.230.0000.01715.32
7.2.220.0070.00415.41
7.2.210.0030.01015.46
7.2.200.0070.00715.34
7.2.190.0030.00615.41
7.2.180.0030.01315.37
7.2.170.0030.00615.30
7.2.80.0200.00915.81
7.2.70.0180.01116.30
7.2.60.0160.01216.19
7.2.50.0230.00916.15
7.2.40.0250.01016.25
7.2.30.0140.01416.20
7.2.20.0250.00616.25
7.2.10.0160.01116.14
7.2.00.0160.00816.02
7.1.330.0070.00716.02
7.1.320.0110.00316.21
7.1.310.0060.00615.94
7.1.300.0060.00615.99
7.1.290.0040.01115.99
7.1.280.0040.00815.98
7.1.270.0060.00915.88
7.1.260.0080.00416.07
7.1.200.0030.01015.80
7.1.190.0190.01015.11
7.1.180.0210.01315.17
7.1.170.0220.00615.14
7.1.160.0280.00315.13
7.1.150.0220.01015.05
7.1.140.0220.00915.08
7.1.130.0230.00815.12
7.1.120.0090.01415.01
7.1.110.0120.00914.90
7.1.100.0130.01014.85
7.1.90.0140.01114.96
7.1.80.0160.00515.15
7.1.70.0160.00814.80
7.1.60.0290.01132.81
7.1.50.0360.01333.10
7.1.40.0320.01232.97
7.1.30.0400.01033.00
7.1.20.0420.01533.05
7.1.10.0230.00714.91
7.1.00.0180.01114.96

preferences:
48.33 ms | 401 KiB | 5 Q