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); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 24
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 87
Branch analysis from position: 51
2 jumps found. (Code = 77) Position 1 = 52, Position 2 = 83
Branch analysis from position: 52
2 jumps found. (Code = 78) Position 1 = 53, Position 2 = 83
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 82
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 76, Position 2 = 79
Branch analysis from position: 76
1 jumps found. (Code = 42) Position 1 = 82
Branch analysis from position: 82
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 79
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 82
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 83
Branch analysis from position: 87
Branch analysis from position: 25
filename:       /in/WMpsJ
function name:  (null)
number of ops:  88
compiled vars:  !0 = $desc, !1 = $uom, !2 = $keywords, !3 = $pkgstring, !4 = $result, !5 = $keyword, !6 = $key, !7 = $firstchar, !8 = $str_ele, !9 = $qty_uom, !10 = $new_arr, !11 = $pos, !12 = $element, !13 = $x, !14 = $chk
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'GLOVE+EXAM+BEST+TCH+ALOE+LTX+MED++10BX%2FCS+100%2FBX'
    3     1        ASSIGN                                                   !1, 'CS'
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $17     
          6        ASSIGN                                                   !2, $17
    6     7        ASSIGN                                                   !3, ''
    7     8        ASSIGN                                                   !4, <array>
    8     9      > FE_RESET_R                                       $21     !2, ->25
         10    > > FE_FETCH_R                                       ~22     $21, !5, ->25
         11    >   ASSIGN                                                   !6, ~22
    9    12        INIT_FCALL                                               'substr'
         13        SEND_VAR                                                 !5
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $24     
         17        ASSIGN                                                   !7, $24
   10    18        INIT_FCALL                                               'is_numeric'
         19        SEND_VAR                                                 !7
         20        DO_ICALL                                         $26     
         21      > JMPZ                                                     $26, ->24
   11    22    >   CONCAT                                           ~27     !5, '%2C'
         23        ASSIGN_OP                                     8          !3, ~27
    8    24    > > JMP                                                      ->10
         25    >   FE_FREE                                                  $21
   14    26        INIT_FCALL                                               'substr'
         27        SEND_VAR                                                 !3
         28        SEND_VAL                                                 0
         29        SEND_VAL                                                 -1
         30        DO_ICALL                                         $29     
         31        ASSIGN                                                   !3, $29
   15    32        CONCAT                                           ~31     !3, '%0A%0A'
         33        ECHO                                                     ~31
   16    34        ASSIGN_DIM                                               !4, 'pkgstring'
         35        OP_DATA                                                  !3
   18    36        INIT_FCALL                                               'explode'
         37        SEND_VAL                                                 '%2C'
         38        SEND_VAR                                                 !3
         39        DO_ICALL                                         $33     
         40        ASSIGN                                                   !8, $33
   19    41        ASSIGN                                                   !9, 1
   20    42        ASSIGN_DIM                                               !10, 0
         43        OP_DATA                                                  ''
   21    44        ASSIGN                                                   !11, 1
   22    45        INIT_FCALL                                               'stripos'
         46        SEND_VAR                                                 !3
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                         $38     
         49        TYPE_CHECK                                  1018          $38
         50      > JMPZ                                                     ~39, ->87
   23    51    > > FE_RESET_R                                       $40     !8, ->83
         52    > > FE_FETCH_R                                       ~41     $40, !12, ->83
         53    >   ASSIGN                                                   !6, ~41
   24    54        INIT_FCALL                                               'stripos'
         55        SEND_VAR                                                 !12
         56        SEND_VAL                                                 '%2F'
         57        DO_ICALL                                         $43     
         58        TYPE_CHECK                                  1018          $43
         59      > JMPZ                                                     ~44, ->82
   25    60    >   INIT_FCALL                                               'stripos'
         61        SEND_VAR                                                 !12
         62        SEND_VAL                                                 '%2F'
         63        DO_ICALL                                         $45     
         64        ASSIGN                                                   !13, $45
   26    65        INIT_FCALL                                               'substr'
         66        SEND_VAR                                                 !12
         67        SUB                                              ~47     !13, 1
         68        SEND_VAL                                                 ~47
         69        SEND_VAL                                                 1
         70        DO_ICALL                                         $48     
         71        ASSIGN                                                   !14, $48
   27    72        INIT_FCALL                                               'is_numeric'
         73        SEND_VAR                                                 !14
         74        DO_ICALL                                         $50     
         75      > JMPZ                                                     $50, ->79
   28    76    >   ASSIGN_DIM                                               !10, 0
         77        OP_DATA                                                  !12
         78      > JMP                                                      ->82
   30    79    >   ASSIGN_DIM                                               !10, !11
         80        OP_DATA                                                  !12
   31    81        PRE_INC                                                  !11
   23    82    > > JMP                                                      ->52
         83    >   FE_FREE                                                  $40
   50    84        INIT_FCALL                                               'print_r'
         85        SEND_VAR                                                 !10
         86        DO_ICALL                                                 
   51    87    > > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.81 ms | 1404 KiB | 23 Q