3v4l.org

run code in 300+ PHP versions simultaneously
<?php $myString = "type:blue, type:red, shift:second, shift:first, category:circle, system:unknown"; $possibleKeys = [ "category", "shift", "type" ]; Foreach($possibleKeys as $key){ preg_match_all("/" . $key . ":(.*?),/", $myString, $m); $new[$key] = $m[1]; } Var_dump($new);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 15
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/XAeRC
function name:  (null)
number of ops:  20
compiled vars:  !0 = $myString, !1 = $possibleKeys, !2 = $key, !3 = $m, !4 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'type%3Ablue%2C+type%3Ared%2C+shift%3Asecond%2C+shift%3Afirst%2C+category%3Acircle%2C+system%3Aunknown'
    4     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $7      !1, ->15
          3    > > FE_FETCH_R                                               $7, !2, ->15
    7     4    >   INIT_FCALL                                               'preg_match_all'
          5        CONCAT                                           ~8      '%2F', !2
          6        CONCAT                                           ~9      ~8, '%3A%28.%2A%3F%29%2C%2F'
          7        SEND_VAL                                                 ~9
          8        SEND_VAR                                                 !0
          9        SEND_REF                                                 !3
         10        DO_ICALL                                                 
    8    11        FETCH_DIM_R                                      ~12     !3, 1
         12        ASSIGN_DIM                                               !4, !2
         13        OP_DATA                                                  ~12
    6    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $7
   10    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.91 ms | 1011 KiB | 15 Q