3v4l.org

run code in 300+ PHP versions simultaneously
<?php $value = "100% Wool"; $separators = [ "/", ",", "&", " AND " ]; $value = str_replace($separators, "|", $value); $candidates = explode("|", $value); foreach($candidates as $candidate) { $percentage = (count($candidates) == 1) ? "100%" : null; if($candidate = trim($candidate)){ if(strpos("%", $candidate) !== false) { list($percentage, $material) = explode("%", $candidate); $percentage .= "%"; } else { $material = $candidate; } $entities = $this->mapping['material']; if($id = $this->exact($material, $entities)) { $material = [ 'material_id' => $id, 'percentage' => $percentage ]; $product['materials'][] = $material; } else { $this->log_errors($product, $this->dictionaries['material'], $value, 'Missing material:' . $value); } } } print_r($product['materials']);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 76
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 76
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 75
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 44
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 63
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 63
Branch analysis from position: 56
Branch analysis from position: 63
Branch analysis from position: 75
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 75
Branch analysis from position: 27
Branch analysis from position: 75
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 76
filename:       /in/VXgil
function name:  (null)
number of ops:  82
compiled vars:  !0 = $value, !1 = $separators, !2 = $candidates, !3 = $candidate, !4 = $percentage, !5 = $material, !6 = $entities, !7 = $id, !8 = $product
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '100%25+Wool'
    4     1        ASSIGN                                                   !1, <array>
   11     2        INIT_FCALL                                               'str_replace'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 '%7C'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $11     
          7        ASSIGN                                                   !0, $11
   12     8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%7C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !2, $13
   13    13      > FE_RESET_R                                       $15     !2, ->76
         14    > > FE_FETCH_R                                               $15, !3, ->76
   14    15    >   COUNT                                            ~16     !2
         16        IS_EQUAL                                                 ~16, 1
         17      > JMPZ                                                     ~17, ->20
         18    >   QM_ASSIGN                                        ~18     '100%25'
         19      > JMP                                                      ->21
         20    >   QM_ASSIGN                                        ~18     null
         21    >   ASSIGN                                                   !4, ~18
   15    22        INIT_FCALL                                               'trim'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                         $20     
         25        ASSIGN                                           ~21     !3, $20
         26      > JMPZ                                                     ~21, ->75
   16    27    >   INIT_FCALL                                               'strpos'
         28        SEND_VAL                                                 '%25'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $22     
         31        TYPE_CHECK                                  1018          $22
         32      > JMPZ                                                     ~23, ->44
   17    33    >   INIT_FCALL                                               'explode'
         34        SEND_VAL                                                 '%25'
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                         $24     
         37        FETCH_LIST_R                                     $25     $24, 0
         38        ASSIGN                                                   !4, $25
         39        FETCH_LIST_R                                     $27     $24, 1
         40        ASSIGN                                                   !5, $27
         41        FREE                                                     $24
   18    42        ASSIGN_OP                                     8          !4, '%25'
         43      > JMP                                                      ->45
   20    44    >   ASSIGN                                                   !5, !3
   23    45    >   FETCH_THIS                                       $31     
         46        FETCH_OBJ_R                                      ~32     $31, 'mapping'
         47        FETCH_DIM_R                                      ~33     ~32, 'material'
         48        ASSIGN                                                   !6, ~33
   24    49        FETCH_THIS                                       $35     
         50        INIT_METHOD_CALL                                         $35, 'exact'
         51        SEND_VAR_EX                                              !5
         52        SEND_VAR_EX                                              !6
         53        DO_FCALL                                      0  $36     
         54        ASSIGN                                           ~37     !7, $36
         55      > JMPZ                                                     ~37, ->63
   26    56    >   INIT_ARRAY                                       ~38     !7, 'material_id'
   27    57        ADD_ARRAY_ELEMENT                                ~38     !4, 'percentage'
   25    58        ASSIGN                                                   !5, ~38
   29    59        FETCH_DIM_W                                      $40     !8, 'materials'
         60        ASSIGN_DIM                                               $40
         61        OP_DATA                                                  !5
         62      > JMP                                                      ->75
   31    63    >   FETCH_THIS                                       $42     
         64        INIT_METHOD_CALL                                         $42, 'log_errors'
         65        SEND_VAR_EX                                              !8
         66        CHECK_FUNC_ARG                                           
         67        FETCH_THIS                                       $43     
         68        FETCH_OBJ_FUNC_ARG                               $44     $43, 'dictionaries'
         69        FETCH_DIM_FUNC_ARG                               $45     $44, 'material'
         70        SEND_FUNC_ARG                                            $45
         71        SEND_VAR_EX                                              !0
         72        CONCAT                                           ~46     'Missing+material%3A', !0
         73        SEND_VAL_EX                                              ~46
         74        DO_FCALL                                      0          
   13    75    > > JMP                                                      ->14
         76    >   FE_FREE                                                  $15
   36    77        INIT_FCALL                                               'print_r'
         78        FETCH_DIM_R                                      ~48     !8, 'materials'
         79        SEND_VAL                                                 ~48
         80        DO_ICALL                                                 
         81      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.96 ms | 1404 KiB | 23 Q