3v4l.org

run code in 500+ PHP versions simultaneously
<?php $item_colors = "Vario Base Unit with steel, large, black/orange"; $result = []; foreach (explode(', ', str_replace('Vario Base Unit with ','', $item_colors)) as $color) { $colors = explode('/', $color); count($colors) === 2 ? array_push($result, ...$colors) : array_push($result, $color); } echo implode(' ', $result); //steel large black orange var_dump($result); // array(4) { // [0]=> // string(5) "steel" // [1]=> // string(5) "large" // [2]=> // string(5) "black" // [3]=> // string(6) "orange" // }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 32
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 32
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 25
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/1JR98
function name:  (null)
number of ops:  39
compiled vars:  !0 = $item_colors, !1 = $result, !2 = $color, !3 = $colors
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'Vario+Base+Unit+with+steel%2C+large%2C+black%2Forange'
    5     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '%2C+'
          4        FRAMELESS_ICALL_3                str_replace         ~6      'Vario+Base+Unit+with+', ''
          5        OP_DATA                                                      !0
          6        SEND_VAL                                                     ~6
          7        DO_ICALL                                             $7      
          8      > FE_RESET_R                                           $8      $7, ->32
          9    > > FE_FETCH_R                                                   $8, !2, ->32
    7    10    >   INIT_FCALL                                                   'explode'
         11        SEND_VAL                                                     '%2F'
         12        SEND_VAR                                                     !2
         13        DO_ICALL                                             $9      
         14        ASSIGN                                                       !3, $9
    8    15        COUNT                                                ~11     !3
         16        IS_IDENTICAL                                                 ~11, 2
         17      > JMPZ                                                         ~12, ->25
         18    >   INIT_FCALL                                                   'array_push'
         19        SEND_REF                                                     !1
         20        SEND_UNPACK                                                  !3
         21        CHECK_UNDEF_ARGS                                             
         22        DO_ICALL                                             $13     
         23        QM_ASSIGN                                            ~14     $13
         24      > JMP                                                          ->30
         25    >   INIT_FCALL                                                   'array_push'
         26        SEND_REF                                                     !1
         27        SEND_VAR                                                     !2
         28        DO_ICALL                                             $15     
         29        QM_ASSIGN                                            ~14     $15
         30    >   FREE                                                         ~14
    6    31      > JMP                                                          ->9
         32    >   FE_FREE                                                      $8
   13    33        FRAMELESS_ICALL_2                implode             ~16     '+', !1
         34        ECHO                                                         ~16
   16    35        INIT_FCALL                                                   'var_dump'
         36        SEND_VAR                                                     !1
         37        DO_ICALL                                                     
   26    38      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.76 ms | 2015 KiB | 16 Q