3v4l.org

run code in 300+ PHP versions simultaneously
<?php $desc = "GLOVE EXAM BEST TCH ALOE LTX MED 10BX/CS 100/BX"; $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); echo $pkgstring."\n\n"; $result['pkgstring'] = $pkgstring; $str_ele = explode(",", $pkgstring); $qty_uom = 1; $new_arr[0] = ""; $pos = 1; if (stripos($pkgstring, $uom) !== false){ 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; // // } } print_r($new_arr); }
Output for git.master_jit, git.master, rfc.property-hooks
10BX/CS,100/BX Array ( [0] => 100/BX [1] => 10BX/CS )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
61 ms | 401 KiB | 8 Q