3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_assoc($var) { return is_array($var) && array_diff_key($var,array_keys(array_keys($var))); } $a = [1, 2, 3, 4, 5]; $b = ['a', 'b', 'c']; $c = ['a' => 1, 'b' => 2, 'c' => 3]; $d = [0 => 1, 1 => 2, 2 => 3]; $e = [1 => 1, 2 => 2, 3 => 3]; $f = [0 => 1, 1 => 2, 2 => 3, 'a' => 4]; $g = 'foo'; $h = 123; var_dump(array_keys($a)); echo '$a '; var_dump(is_assoc($a)); echo '$b '; var_dump(is_assoc($b)); echo '$c '; var_dump(is_assoc($c)); echo '$d '; var_dump(is_assoc($d)); echo '$e '; var_dump(is_assoc($e)); echo '$f '; var_dump(is_assoc($f)); echo '$g '; var_dump(is_assoc($g)); echo '$h '; var_dump(is_assoc($h));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ldlsb
function name:  (null)
number of ops:  71
compiled vars:  !0 = $a, !1 = $b, !2 = $c, !3 = $d, !4 = $e, !5 = $f, !6 = $g, !7 = $h
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN                                                   !2, <array>
   10     3        ASSIGN                                                   !3, <array>
   11     4        ASSIGN                                                   !4, <array>
   12     5        ASSIGN                                                   !5, <array>
   13     6        ASSIGN                                                   !6, 'foo'
   14     7        ASSIGN                                                   !7, 123
   16     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'array_keys'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $16     
         12        SEND_VAR                                                 $16
         13        DO_ICALL                                                 
   18    14        ECHO                                                     '%24a+'
   19    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'is_assoc'
         17        SEND_VAR                                                 !0
         18        DO_FCALL                                      0  $18     
         19        SEND_VAR                                                 $18
         20        DO_ICALL                                                 
   21    21        ECHO                                                     '%24b+'
   22    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL                                               'is_assoc'
         24        SEND_VAR                                                 !1
         25        DO_FCALL                                      0  $20     
         26        SEND_VAR                                                 $20
         27        DO_ICALL                                                 
   24    28        ECHO                                                     '%24c+'
   25    29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL                                               'is_assoc'
         31        SEND_VAR                                                 !2
         32        DO_FCALL                                      0  $22     
         33        SEND_VAR                                                 $22
         34        DO_ICALL                                                 
   27    35        ECHO                                                     '%24d+'
   28    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'is_assoc'
         38        SEND_VAR                                                 !3
         39        DO_FCALL                                      0  $24     
         40        SEND_VAR                                                 $24
         41        DO_ICALL                                                 
   30    42        ECHO                                                     '%24e+'
   31    43        INIT_FCALL                                               'var_dump'
         44        INIT_FCALL                                               'is_assoc'
         45        SEND_VAR                                                 !4
         46        DO_FCALL                                      0  $26     
         47        SEND_VAR                                                 $26
         48        DO_ICALL                                                 
   33    49        ECHO                                                     '%24f+'
   34    50        INIT_FCALL                                               'var_dump'
         51        INIT_FCALL                                               'is_assoc'
         52        SEND_VAR                                                 !5
         53        DO_FCALL                                      0  $28     
         54        SEND_VAR                                                 $28
         55        DO_ICALL                                                 
   36    56        ECHO                                                     '%24g+'
   37    57        INIT_FCALL                                               'var_dump'
         58        INIT_FCALL                                               'is_assoc'
         59        SEND_VAR                                                 !6
         60        DO_FCALL                                      0  $30     
         61        SEND_VAR                                                 $30
         62        DO_ICALL                                                 
   39    63        ECHO                                                     '%24h+'
   40    64        INIT_FCALL                                               'var_dump'
         65        INIT_FCALL                                               'is_assoc'
         66        SEND_VAR                                                 !7
         67        DO_FCALL                                      0  $32     
         68        SEND_VAR                                                 $32
         69        DO_ICALL                                                 
         70      > RETURN                                                   1

Function is_assoc:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/Ldlsb
function name:  is_assoc
number of ops:  16
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        TYPE_CHECK                                  128  ~1      !0
          2      > JMPZ_EX                                          ~1      ~1, ->14
          3    >   INIT_FCALL                                               'array_diff_key'
          4        SEND_VAR                                                 !0
          5        INIT_FCALL                                               'array_keys'
          6        INIT_FCALL                                               'array_keys'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                         $2      
          9        SEND_VAR                                                 $2
         10        DO_ICALL                                         $3      
         11        SEND_VAR                                                 $3
         12        DO_ICALL                                         $4      
         13        BOOL                                             ~1      $4
         14    > > RETURN                                                   ~1
    4    15*     > RETURN                                                   null

End of function is_assoc

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.37 ms | 1403 KiB | 27 Q