3v4l.org

run code in 300+ PHP versions simultaneously
<?php $select = [ 'foo', 'bar', [ 'size' => 128, 'type' => 'png' ], 'baz', 'qux' ]; function convert($in) { $out = []; for ($i = 0, $m = count($in); $i < $m; $i++) { $current = $in[$i]; $next = $in[$i + 1] ?? null; if (!is_string($current)) { throw new \Exception('Malformed field list.'); } if (is_array($next)) { $out[$current] = $next; $i++; } else { $out[$current] = true; } } return $out; } var_dump(convert($select));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a1094
function name:  (null)
number of ops:  8
compiled vars:  !0 = $select
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   33     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'convert'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function convert:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 20
Branch analysis from position: 16
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
Branch analysis from position: 6
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 6
Branch analysis from position: 31
Branch analysis from position: 6
filename:       /in/a1094
function name:  convert
number of ops:  33
compiled vars:  !0 = $in, !1 = $out, !2 = $i, !3 = $m, !4 = $current, !5 = $next
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        ASSIGN                                                   !1, <array>
   14     2        ASSIGN                                                   !2, 0
          3        COUNT                                            ~8      !0
          4        ASSIGN                                                   !3, ~8
          5      > JMP                                                      ->29
   15     6    >   FETCH_DIM_R                                      ~10     !0, !2
          7        ASSIGN                                                   !4, ~10
   16     8        ADD                                              ~12     !2, 1
          9        FETCH_DIM_IS                                     ~13     !0, ~12
         10        COALESCE                                         ~14     ~13
         11        QM_ASSIGN                                        ~14     null
         12        ASSIGN                                                   !5, ~14
   18    13        TYPE_CHECK                                   64  ~16     !4
         14        BOOL_NOT                                         ~17     ~16
         15      > JMPZ                                                     ~17, ->20
   19    16    >   NEW                                              $18     'Exception'
         17        SEND_VAL_EX                                              'Malformed+field+list.'
         18        DO_FCALL                                      0          
         19      > THROW                                         0          $18
   22    20    >   TYPE_CHECK                                  128          !5
         21      > JMPZ                                                     ~20, ->26
   23    22    >   ASSIGN_DIM                                               !1, !4
         23        OP_DATA                                                  !5
   24    24        PRE_INC                                                  !2
         25      > JMP                                                      ->28
   26    26    >   ASSIGN_DIM                                               !1, !4
         27        OP_DATA                                                  <true>
   14    28    >   PRE_INC                                                  !2
         29    >   IS_SMALLER                                               !2, !3
         30      > JMPNZ                                                    ~25, ->6
   30    31    > > RETURN                                                   !1
   31    32*     > RETURN                                                   null

End of function convert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.04 ms | 1394 KiB | 16 Q