3v4l.org

run code in 300+ PHP versions simultaneously
<?php $select = [ 'foo', 'bar', [ 'size' => 128, 'type' => 'png' ], 'baz', 'qux' ]; function convert($in) { if (!isset($in[0])) { return $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/VJPRT
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>
   37     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
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 5
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 10
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 30
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 10
Branch analysis from position: 35
Branch analysis from position: 10
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 10
Branch analysis from position: 35
Branch analysis from position: 10
filename:       /in/VJPRT
function name:  convert
number of ops:  37
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        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !0, 0
          2        BOOL_NOT                                         ~7      ~6
          3      > JMPZ                                                     ~7, ->5
   14     4    > > RETURN                                                   !0
   17     5    >   ASSIGN                                                   !1, <array>
   18     6        ASSIGN                                                   !2, 0
          7        COUNT                                            ~10     !0
          8        ASSIGN                                                   !3, ~10
          9      > JMP                                                      ->33
   19    10    >   FETCH_DIM_R                                      ~12     !0, !2
         11        ASSIGN                                                   !4, ~12
   20    12        ADD                                              ~14     !2, 1
         13        FETCH_DIM_IS                                     ~15     !0, ~14
         14        COALESCE                                         ~16     ~15
         15        QM_ASSIGN                                        ~16     null
         16        ASSIGN                                                   !5, ~16
   22    17        TYPE_CHECK                                   64  ~18     !4
         18        BOOL_NOT                                         ~19     ~18
         19      > JMPZ                                                     ~19, ->24
   23    20    >   NEW                                              $20     'Exception'
         21        SEND_VAL_EX                                              'Malformed+field+list.'
         22        DO_FCALL                                      0          
         23      > THROW                                         0          $20
   26    24    >   TYPE_CHECK                                  128          !5
         25      > JMPZ                                                     ~22, ->30
   27    26    >   ASSIGN_DIM                                               !1, !4
         27        OP_DATA                                                  !5
   28    28        PRE_INC                                                  !2
         29      > JMP                                                      ->32
   30    30    >   ASSIGN_DIM                                               !1, !4
         31        OP_DATA                                                  <true>
   18    32    >   PRE_INC                                                  !2
         33    >   IS_SMALLER                                               !2, !3
         34      > JMPNZ                                                    ~27, ->10
   34    35    > > RETURN                                                   !1
   35    36*     > RETURN                                                   null

End of function convert

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.19 ms | 1403 KiB | 16 Q