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); // 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++; } } // // if (stripos($element, '/'.$uom) !== false) { // $x = stripos($element, '/'.$uom); // $chk = substr($element, $x-1, 1); // if (is_numeric($chk)) { // $size = substr($element, 0, $x); // $qty_uom *= $size; // break; // } // if (ctype_alpha($chk)) { // $new = preg_replace('/[^0-9]/', '', $element); // echo $new; // } // // } else { // // echo $element; // // } } // 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; } } } echo $qty_uom;

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.0150.00316.88
8.3.60.0090.00618.43
8.3.50.0120.00517.50
8.3.40.0030.01218.95
8.3.30.0070.00719.09
8.3.20.0090.00018.90
8.3.10.0040.00423.64
8.3.00.0050.00223.56
8.2.190.0150.00016.58
8.2.180.0000.01425.92
8.2.170.0060.00922.96
8.2.160.0110.00319.29
8.2.150.0000.00824.18
8.2.140.0080.00024.66
8.2.130.0040.00420.43
8.2.120.0000.00726.35
8.2.110.0100.00020.38
8.2.100.0090.00317.86
8.2.90.0040.00419.22
8.2.80.0040.00417.97
8.2.70.0100.00018.04
8.2.60.0030.00518.05
8.2.50.0000.00818.10
8.2.40.0070.00019.52
8.2.30.0040.00419.28
8.2.20.0000.00718.07
8.2.10.0070.00019.54
8.2.00.0070.00019.51
8.1.280.0070.00725.92
8.1.270.0040.00421.98
8.1.260.0080.00026.35
8.1.250.0080.00028.09
8.1.240.0080.00319.39
8.1.230.0070.00419.12
8.1.220.0080.00017.80
8.1.210.0000.00818.77
8.1.200.0030.00617.60
8.1.190.0030.00517.25
8.1.180.0050.00318.10
8.1.170.0060.00318.82
8.1.160.0000.00718.92
8.1.150.0040.00418.89
8.1.140.0040.00419.69
8.1.130.0000.00719.05
8.1.120.0040.00417.64
8.1.110.0040.00417.52
8.1.100.0000.00717.51
8.1.90.0050.00517.59
8.1.80.0050.00217.70
8.1.70.0030.00317.53
8.1.60.0030.00517.63
8.1.50.0040.00417.63
8.1.40.0040.00417.59
8.1.30.0070.00317.89
8.1.20.0000.00817.74
8.1.10.0040.00417.74
8.1.00.0080.00017.66
8.0.300.0040.00418.77
8.0.290.0080.00016.75
8.0.280.0050.00318.42
8.0.270.0050.00317.30
8.0.260.0000.00717.18
8.0.250.0040.00417.18
8.0.240.0000.00717.19
8.0.230.0030.00317.02
8.0.220.0040.00417.07
8.0.210.0050.00217.06
8.0.200.0050.00217.13
8.0.190.0040.00417.13
8.0.180.0050.00217.12
8.0.170.0060.00317.05
8.0.160.0050.00217.03
8.0.150.0030.00516.89
8.0.140.0080.00016.97
8.0.130.0030.00313.47
8.0.120.0000.00716.94
8.0.110.0060.00317.04
8.0.100.0030.00517.09
8.0.90.0070.00016.89
8.0.80.0120.00717.03
8.0.70.0000.00717.09
8.0.60.0000.00817.06
8.0.50.0040.00416.94
8.0.30.0100.01017.29
8.0.20.0130.00517.40
8.0.10.0040.00417.14
8.0.00.0060.01216.96
7.4.330.0050.00015.55
7.4.320.0000.00816.82
7.4.300.0000.00616.84
7.4.290.0030.00316.86
7.4.280.0080.00016.84
7.4.270.0030.00316.84
7.4.260.0040.00616.70
7.4.250.0000.00716.65
7.4.240.0070.00016.63
7.4.230.0070.00016.84
7.4.220.0030.00616.57
7.4.210.0070.00816.68
7.4.200.0030.00316.89
7.4.160.0110.00516.93
7.4.140.0110.00617.86
7.4.130.0110.00616.63
7.4.120.0070.01416.77
7.4.110.0120.00616.60
7.4.100.0070.01416.58
7.4.90.0100.00916.82
7.4.80.0100.00919.39
7.4.70.0070.01416.85
7.4.60.0090.00616.68
7.4.50.0090.00916.72
7.4.40.0130.00316.63
7.4.00.0040.00815.20
7.3.330.0050.00013.34
7.3.320.0050.00013.47
7.3.310.0040.00416.46
7.3.300.0000.00816.46
7.3.290.0040.00416.53
7.3.280.0170.00716.52
7.3.260.0080.00916.60
7.3.240.0100.01116.56
7.3.230.0100.00716.75
7.3.210.0070.01716.78
7.3.200.0130.00916.70
7.3.190.0150.00616.70
7.3.180.0030.01316.60
7.3.170.0070.01116.69
7.3.160.0110.00816.68
7.2.330.0090.01516.79
7.2.320.0000.02016.96
7.2.310.0100.00716.87
7.2.300.0090.00616.80
7.2.290.0090.00916.93
7.2.80.0200.00614.97
7.2.70.0190.01215.19
7.2.60.0140.01115.37
7.2.50.0160.01015.23
7.2.40.0130.01315.00
7.2.30.0130.01315.29
7.2.20.0170.00715.38
7.2.10.0170.00715.25
7.2.00.0200.01115.34
7.1.200.0210.00715.85
7.1.190.0170.00714.02
7.1.180.0220.00314.06
7.1.170.0130.01014.28
7.1.160.0210.00414.11
7.1.150.0170.00714.19
7.1.140.0200.00313.81
7.1.130.0190.00514.12
7.1.120.0230.00314.07
7.1.110.1010.00614.21
7.1.100.0220.00314.14
7.1.90.0180.00713.84
7.1.80.0360.01314.05
7.1.70.0230.00413.95
7.1.60.0400.00631.73
7.1.50.0350.01632.18
7.1.40.0400.01032.44
7.1.30.0330.01332.15
7.1.20.0340.01232.05
7.1.10.0290.00014.11
7.1.00.0240.00314.16

preferences:
46.41 ms | 401 KiB | 5 Q