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; 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/hkVSO
function name:  (null)
number of ops:  65
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
-------------------------------------------------------------------------------------
    6     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, <array>
    8     2        ASSIGN                                                   !2, <array>
    9     3        ASSIGN                                                   !3, <array>
   10     4        ASSIGN                                                   !4, <array>
   11     5        ASSIGN                                                   !5, <array>
   12     6        ASSIGN                                                   !6, 'foo'
   13     7        ASSIGN                                                   !7, 123
   15     8        ECHO                                                     '%24a+'
   16     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'is_assoc'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $16     
         13        SEND_VAR                                                 $16
         14        DO_ICALL                                                 
   18    15        ECHO                                                     '%24b+'
   19    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'is_assoc'
         18        SEND_VAR                                                 !1
         19        DO_FCALL                                      0  $18     
         20        SEND_VAR                                                 $18
         21        DO_ICALL                                                 
   21    22        ECHO                                                     '%24c+'
   22    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL                                               'is_assoc'
         25        SEND_VAR                                                 !2
         26        DO_FCALL                                      0  $20     
         27        SEND_VAR                                                 $20
         28        DO_ICALL                                                 
   24    29        ECHO                                                     '%24d+'
   25    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'is_assoc'
         32        SEND_VAR                                                 !3
         33        DO_FCALL                                      0  $22     
         34        SEND_VAR                                                 $22
         35        DO_ICALL                                                 
   27    36        ECHO                                                     '%24e+'
   28    37        INIT_FCALL                                               'var_dump'
         38        INIT_FCALL                                               'is_assoc'
         39        SEND_VAR                                                 !4
         40        DO_FCALL                                      0  $24     
         41        SEND_VAR                                                 $24
         42        DO_ICALL                                                 
   30    43        ECHO                                                     '%24f+'
   31    44        INIT_FCALL                                               'var_dump'
         45        INIT_FCALL                                               'is_assoc'
         46        SEND_VAR                                                 !5
         47        DO_FCALL                                      0  $26     
         48        SEND_VAR                                                 $26
         49        DO_ICALL                                                 
   33    50        ECHO                                                     '%24g+'
   34    51        INIT_FCALL                                               'var_dump'
         52        INIT_FCALL                                               'is_assoc'
         53        SEND_VAR                                                 !6
         54        DO_FCALL                                      0  $28     
         55        SEND_VAR                                                 $28
         56        DO_ICALL                                                 
   36    57        ECHO                                                     '%24h+'
   37    58        INIT_FCALL                                               'var_dump'
         59        INIT_FCALL                                               'is_assoc'
         60        SEND_VAR                                                 !7
         61        DO_FCALL                                      0  $30     
         62        SEND_VAR                                                 $30
         63        DO_ICALL                                                 
         64      > 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/hkVSO
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:
163.34 ms | 1403 KiB | 27 Q