3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sales_people = array( '2' => array( 'states' => array('NY', 'NJ', 'CT', 'MA', 'VT', 'ME'), 'codes' => array('CA1', 'US7', 'UT9') ), '5' => array( 'states' => array('FL', 'GA', 'SC', 'NC', 'TN'), 'codes' => array('VA4', 'VA8', 'VA3') ) ); function populateLookup(array $sets): array { $lookup = []; foreach ($sets as $id => $haystacks) { foreach ($haystacks as $haystack) { $lookup += array_fill_keys($haystack, $id); } } return $lookup; } $map = populateLookup($sales_people); var_export($map); echo "\n---\n"; var_export($map['CT'] ?? null);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/60Kov
function name:  (null)
number of ops:  16
compiled vars:  !0 = $sales_people, !1 = $map
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'populatelookup'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   25     5        INIT_FCALL                                               'var_export'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                                 
   26     8        ECHO                                                     '%0A---%0A'
   27     9        INIT_FCALL                                               'var_export'
         10        FETCH_DIM_IS                                     ~6      !1, 'CT'
         11        COALESCE                                         ~7      ~6
         12        QM_ASSIGN                                        ~7      null
         13        SEND_VAL                                                 ~7
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function populatelookup:
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
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 13
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/60Kov
function name:  populateLookup
number of ops:  20
compiled vars:  !0 = $sets, !1 = $lookup, !2 = $haystacks, !3 = $id, !4 = $haystack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   16     1        ASSIGN                                                   !1, <array>
   17     2      > FE_RESET_R                                       $6      !0, ->15
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->15
          4    >   ASSIGN                                                   !3, ~7
   18     5      > FE_RESET_R                                       $9      !2, ->13
          6    > > FE_FETCH_R                                               $9, !4, ->13
   19     7    >   INIT_FCALL                                               'array_fill_keys'
          8        SEND_VAR                                                 !4
          9        SEND_VAR                                                 !3
         10        DO_ICALL                                         $10     
         11        ASSIGN_OP                                     1          !1, $10
   18    12      > JMP                                                      ->6
         13    >   FE_FREE                                                  $9
   17    14      > JMP                                                      ->3
         15    >   FE_FREE                                                  $6
   22    16        VERIFY_RETURN_TYPE                                       !1
         17      > RETURN                                                   !1
   23    18*       VERIFY_RETURN_TYPE                                       
         19*     > RETURN                                                   null

End of function populatelookup

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.33 ms | 1018 KiB | 16 Q