3v4l.org

run code in 300+ PHP versions simultaneously
<?php $desc = "GLOVE EXAM BEST TCH ALOE LTX MED 100/BX 10BX/CS"; $uom = "BX"; $keywords = explode(" ", $desc); // print_r($keywords); $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.40.0120.00319.00
8.3.30.0110.00418.79
8.3.20.0000.00819.04
8.3.10.0000.00723.51
8.3.00.0040.00423.53
8.2.170.0130.00322.96
8.2.160.0110.00419.24
8.2.150.0080.00024.18
8.2.140.0070.00024.66
8.2.130.0000.00720.52
8.2.120.0050.00326.35
8.2.110.0000.01021.00
8.2.100.0090.00319.95
8.2.90.0000.00919.36
8.2.80.0040.00417.97
8.2.70.0000.00818.04
8.2.60.0000.00818.04
8.2.50.0030.00618.10
8.2.40.0040.00419.46
8.2.30.0000.00719.49
8.2.20.0020.00518.13
8.2.10.0000.00719.36
8.2.00.0040.00419.60
8.1.270.0080.00020.33
8.1.260.0040.00426.35
8.1.250.0080.00028.09
8.1.240.0100.01019.13
8.1.230.0070.00419.01
8.1.220.0080.00017.79
8.1.210.0040.00418.77
8.1.200.0030.00617.60
8.1.190.0030.00517.48
8.1.180.0000.00818.10
8.1.170.0030.00618.88
8.1.160.0020.00518.95
8.1.150.0050.00318.82
8.1.140.0080.00019.53
8.1.130.0000.00719.04
8.1.120.0040.00417.67
8.1.110.0000.00717.59
8.1.100.0080.00017.59
8.1.90.0000.00817.67
8.1.80.0040.00417.52
8.1.70.0000.00717.56
8.1.60.0030.00517.74
8.1.50.0040.00417.66
8.1.40.0030.00517.73
8.1.30.0040.00717.72
8.1.20.0000.00817.68
8.1.10.0030.00517.75
8.1.00.0000.00817.67
8.0.300.0000.01118.77
8.0.290.0040.00417.00
8.0.280.0000.00718.50
8.0.270.0030.00317.32
8.0.260.0070.00017.25
8.0.250.0030.00317.16
8.0.240.0030.00317.14
8.0.230.0000.00817.10
8.0.220.0000.00816.96
8.0.210.0000.00717.07
8.0.200.0030.00317.00
8.0.190.0000.00817.02
8.0.180.0000.00717.11
8.0.170.0000.00916.97
8.0.160.0000.00717.14
8.0.150.0040.00416.90
8.0.140.0040.00417.07
8.0.130.0030.00313.48
8.0.120.0070.00016.92
8.0.110.0040.00417.06
8.0.100.0000.00817.03
8.0.90.0040.00416.97
8.0.80.0080.00917.07
8.0.70.0040.00417.07
8.0.60.0040.00417.07
8.0.50.0060.00316.90
8.0.30.0120.00617.20
8.0.20.0060.01117.40
8.0.10.0000.00717.30
8.0.00.0110.00716.96
7.4.330.0030.00315.55
7.4.320.0050.00516.85
7.4.300.0000.00616.88
7.4.290.0030.00316.73
7.4.280.0000.00716.71
7.4.270.0030.00316.84
7.4.260.0000.00716.72
7.4.250.0070.00016.68
7.4.240.0030.00316.73
7.4.230.0030.00316.83
7.4.220.0070.00016.85
7.4.210.0070.00916.85
7.4.200.0030.00416.76
7.4.160.0100.00616.77
7.4.140.0120.00717.86
7.4.130.0090.00916.77
7.4.120.0110.01016.71
7.4.110.0130.00916.69
7.4.100.0170.00716.82
7.4.90.0070.01116.57
7.4.80.0070.01119.39
7.4.70.0110.00616.77
7.4.60.0120.00616.80
7.4.50.0060.00916.64
7.4.40.0120.00616.72
7.4.00.0070.00815.27
7.3.330.0000.00613.31
7.3.320.0000.00513.34
7.3.310.0030.00316.38
7.3.300.0000.00716.48
7.3.290.0030.00516.48
7.3.280.0030.01216.57
7.3.260.0090.00916.61
7.3.240.0110.00816.82
7.3.230.0070.01016.39
7.3.210.0100.01316.88
7.3.200.0100.01016.35
7.3.190.0100.00916.49
7.3.180.0080.00816.69
7.3.170.0060.01016.52
7.3.160.0030.01916.74
7.3.120.0040.01614.96
7.3.110.0040.01115.25
7.3.100.0000.01615.24
7.3.90.0040.00715.09
7.3.80.0030.00615.14
7.3.70.0000.00915.16
7.3.60.0030.01014.70
7.3.50.0070.01114.91
7.3.40.0100.00315.10
7.3.30.0030.01215.08
7.3.20.0070.01117.11
7.3.10.0100.00716.92
7.3.00.0060.00916.71
7.2.330.0100.00716.69
7.2.320.0090.00916.64
7.2.310.0160.00616.89
7.2.300.0110.00716.86
7.2.290.0130.00416.75
7.2.250.0100.01015.23
7.2.240.0130.00615.29
7.2.230.0030.01415.24
7.2.220.0100.00715.29
7.2.210.0000.01215.32
7.2.200.0070.00315.30
7.2.190.0030.01015.27
7.2.180.0030.00715.07
7.2.170.0040.01215.29
7.2.130.0110.00716.87
7.2.120.0110.00716.87
7.2.110.0000.01816.93
7.2.100.0110.00716.91
7.2.90.0180.00316.96
7.2.80.0240.00915.94
7.2.70.0150.01016.08
7.2.60.0190.00716.06
7.2.50.0140.00916.08
7.2.40.0190.00415.90
7.2.30.0150.00715.96
7.2.20.0130.01016.02
7.2.10.0190.00616.12
7.2.00.0180.00916.13
7.1.330.0070.00716.15
7.1.320.0060.00315.78
7.1.310.0030.01015.92
7.1.300.0100.00316.21
7.1.290.0070.00415.98
7.1.280.0090.00615.99
7.1.270.0060.00915.89
7.1.260.0030.00816.05
7.1.250.0140.00615.70
7.1.200.0000.01115.97
7.1.190.0220.01014.30
7.1.180.0220.00714.14
7.1.170.0810.01014.26
7.1.160.0370.00314.03
7.1.150.0180.00914.04
7.1.140.0220.01114.00
7.1.130.0210.00714.18
7.1.120.0180.01113.98
7.1.110.0220.00614.20
7.1.100.0210.00714.13
7.1.90.0290.00314.29
7.1.80.0240.00814.13
7.1.70.0200.01014.06
7.1.60.0480.00031.97
7.1.50.0410.01132.10
7.1.40.0470.00632.18
7.1.30.0430.01032.24
7.1.20.0410.01332.22
7.1.10.0300.00714.07
7.1.00.0190.01513.91

preferences:
56.08 ms | 400 KiB | 5 Q