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 { } } } print_r($product['materials']);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 64
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 64
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 = 63
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 = 63
Branch analysis from position: 63
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 63
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: 63
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 63
Branch analysis from position: 27
Branch analysis from position: 63
Branch analysis from position: 64
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 64
filename:       /in/NkHBc
function name:  (null)
number of ops:  70
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
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '100%25+Wool'
    3     1        ASSIGN                                                   !1, <array>
   10     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
   11     8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '%7C'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $13     
         12        ASSIGN                                                   !2, $13
   12    13      > FE_RESET_R                                       $15     !2, ->64
         14    > > FE_FETCH_R                                               $15, !3, ->64
   13    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
   14    22        INIT_FCALL                                               'trim'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                         $20     
         25        ASSIGN                                           ~21     !3, $20
         26      > JMPZ                                                     ~21, ->63
   15    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
   16    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
   17    42        ASSIGN_OP                                     8          !4, '%25'
         43      > JMP                                                      ->45
   19    44    >   ASSIGN                                                   !5, !3
   22    45    >   FETCH_THIS                                       $31     
         46        FETCH_OBJ_R                                      ~32     $31, 'mapping'
         47        FETCH_DIM_R                                      ~33     ~32, 'material'
         48        ASSIGN                                                   !6, ~33
   23    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
   25    56    >   INIT_ARRAY                                       ~38     !7, 'material_id'
   26    57        ADD_ARRAY_ELEMENT                                ~38     !4, 'percentage'
   24    58        ASSIGN                                                   !5, ~38
   28    59        FETCH_DIM_W                                      $40     !8, 'materials'
         60        ASSIGN_DIM                                               $40
         61        OP_DATA                                                  !5
         62      > JMP                                                      ->63
   12    63    > > JMP                                                      ->14
         64    >   FE_FREE                                                  $15
   35    65        INIT_FCALL                                               'print_r'
         66        FETCH_DIM_R                                      ~42     !8, 'materials'
         67        SEND_VAL                                                 ~42
         68        DO_ICALL                                                 
         69      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.06 ms | 1400 KiB | 23 Q