3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ['level_id' => 1, 'level' => 'Trivial', 'description' => 'Foobar'], ['level_id' => 2, 'level' => 'Moderate', 'description' => 'Foobar'], ['level_id' => 3, 'level' => 'Challenging', 'description' => 'Foobar'], ['level_id' => 4, 'level' => 'Formidable'], ]; function toLookup(array $array): array { foreach ($array as $row) { $result[array_shift($row)] = count($row) === 1 ? current($row) : $row; } return $result ?? []; } var_export(toLookup($array));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vgP3V
function name:  (null)
number of ops:  8
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        INIT_FCALL                                               'var_export'
          2        INIT_FCALL                                               'tolookup'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function tolookup:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 18
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/vgP3V
function name:  toLookup
number of ops:  25
compiled vars:  !0 = $array, !1 = $row, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   12     1      > FE_RESET_R                                       $3      !0, ->18
          2    > > FE_FETCH_R                                               $3, !1, ->18
   13     3    >   INIT_FCALL                                               'array_shift'
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $4      
          6        COUNT                                            ~6      !1
          7        IS_IDENTICAL                                             ~6, 1
          8      > JMPZ                                                     ~7, ->14
          9    >   INIT_FCALL                                               'current'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $8      
         12        QM_ASSIGN                                        ~9      $8
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~9      !1
         15    >   ASSIGN_DIM                                               !2, $4
         16        OP_DATA                                                  ~9
   12    17      > JMP                                                      ->2
         18    >   FE_FREE                                                  $3
   15    19        COALESCE                                         ~10     !2
         20        QM_ASSIGN                                        ~10     <array>
         21        VERIFY_RETURN_TYPE                                       ~10
         22      > RETURN                                                   ~10
   16    23*       VERIFY_RETURN_TYPE                                       
         24*     > RETURN                                                   null

End of function tolookup

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.71 ms | 1009 KiB | 17 Q