3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sales_search($arr, $needle) { foreach ($arr as $id => $data) { if (in_array($needle, $data['states'])) { return $id; } if (in_array($needle, $data['codes'])) { return $id; } } return false; } $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') ) ); var_dump(sales_search($sales_people, 'CA1'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ahtFb
function name:  (null)
number of ops:  9
compiled vars:  !0 = $sales_people
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN                                                   !0, <array>
   24     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'sales_search'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'CA1'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function sales_search:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 22
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 22
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/ahtFb
function name:  sales_search
number of ops:  25
compiled vars:  !0 = $arr, !1 = $needle, !2 = $data, !3 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2      > FE_RESET_R                                       $4      !0, ->22
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->22
          4    >   ASSIGN                                                   !3, ~5
    4     5        INIT_FCALL                                               'in_array'
          6        SEND_VAR                                                 !1
          7        FETCH_DIM_R                                      ~7      !2, 'states'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10      > JMPZ                                                     $8, ->13
    5    11    >   FE_FREE                                                  $4
         12      > RETURN                                                   !3
    8    13    >   INIT_FCALL                                               'in_array'
         14        SEND_VAR                                                 !1
         15        FETCH_DIM_R                                      ~9      !2, 'codes'
         16        SEND_VAL                                                 ~9
         17        DO_ICALL                                         $10     
         18      > JMPZ                                                     $10, ->21
    9    19    >   FE_FREE                                                  $4
         20      > RETURN                                                   !3
    3    21    > > JMP                                                      ->3
         22    >   FE_FREE                                                  $4
   12    23      > RETURN                                                   <false>
   13    24*     > RETURN                                                   null

End of function sales_search

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.64 ms | 1394 KiB | 18 Q