3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getColors($item_colors, $result = []){ preg_match_all('/(\w+),|(\w+)\/(\w+)/', $item_colors, $colors); foreach ($colors as $key => $value) { if ($key === 0) continue; array_push($result, ...$value); } return array_filter($result); } $item_colors = "Vario Base Unit with steel, large, black/orange"; echo implode(' ', getColors($item_colors)); //steel large black orange var_dump(getColors($item_colors)); // array(4) { // [0]=> // string(5) "steel" // [1]=> // string(5) "large" // [5]=> // string(5) "black" // [8]=> // string(6) "orange" // }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JqTN1
function name:  (null)
number of ops:  13
compiled vars:  !0 = $item_colors
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                       !0, 'Vario+Base+Unit+with+steel%2C+large%2C+black%2Forange'
   15     1        INIT_FCALL                                                   'getcolors'
          2        SEND_VAR                                                     !0
          3        DO_FCALL                                          0  $2      
          4        FRAMELESS_ICALL_2                implode             ~3      '+', $2
          5        ECHO                                                         ~3
   18     6        INIT_FCALL                                                   'var_dump'
          7        INIT_FCALL                                                   'getcolors'
          8        SEND_VAR                                                     !0
          9        DO_FCALL                                          0  $4      
         10        SEND_VAR                                                     $4
         11        DO_ICALL                                                     
   28    12      > RETURN                                                       1

Function getcolors:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 19
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 19
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/JqTN1
function name:  getColors
number of ops:  25
compiled vars:  !0 = $item_colors, !1 = $result, !2 = $colors, !3 = $value, !4 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV_INIT                                            !1      <array>
    4     2        INIT_FCALL                                                   'preg_match_all'
          3        SEND_VAL                                                     '%2F%28%5Cw%2B%29%2C%7C%28%5Cw%2B%29%5C%2F%28%5Cw%2B%29%2F'
          4        SEND_VAR                                                     !0
          5        SEND_REF                                                     !2
          6        DO_ICALL                                                     
    5     7      > FE_RESET_R                                           $6      !2, ->19
          8    > > FE_FETCH_R                                           ~7      $6, !3, ->19
          9    >   ASSIGN                                                       !4, ~7
    6    10        IS_IDENTICAL                                                 !4, 0
         11      > JMPZ                                                         ~9, ->13
         12    > > JMP                                                          ->8
    7    13    >   INIT_FCALL                                                   'array_push'
         14        SEND_REF                                                     !1
         15        SEND_UNPACK                                                  !3
         16        CHECK_UNDEF_ARGS                                             
         17        DO_ICALL                                                     
    5    18      > JMP                                                          ->8
         19    >   FE_FREE                                                      $6
    9    20        INIT_FCALL                                                   'array_filter'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                             $11     
         23      > RETURN                                                       $11
   10    24*     > RETURN                                                       null

End of function getcolors

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.87 ms | 3374 KiB | 20 Q