3v4l.org

run code in 300+ PHP versions simultaneously
<?php // string, null, bool, float, largest specified previous index function isIndexedArray($array) { return !(bool)count(array_filter(array_keys($array), 'is_string')); } $a4 = $a2; unset($a4[2]); print_r($a4); var_dump(isIndexedArray('a')); // false var_dump(isSequentialArray([])); // true/undefined var_dump(isSequentialArray(['a'])); // true var_dump(isSequentialArray(['a' => 1])); // false var_dump(isSequentialArray(array(0 => 'a', 1 => 'b'))); // true var_dump(isSequentialArray(array(0 => 'a', 5 => 'b'))); // true var_dump(isSequentialArray(array('a', 'b', 'c'))); // false var_dump(isSequentialArray(array("0" => 'a', "1" => 'b', "2" => 'c'))); // false var_dump(isSequentialArray(array("1" => 'a', "0" => 'b', "2" => 'c'))); // true var_dump(isSequentialArray(array("a" => 'a', "b" => 'b', "c" => 'c'))); // true
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LO1PD
function name:  (null)
number of ops:  66
compiled vars:  !0 = $a4, !1 = $a2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ASSIGN                                                   !0, !1
    9     1        UNSET_DIM                                                !0, 2
   10     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   12     5        INIT_FCALL                                               'var_dump'
          6        INIT_FCALL                                               'isindexedarray'
          7        SEND_VAL                                                 'a'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   13    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         13        SEND_VAL_EX                                              <array>
         14        DO_FCALL                                      0  $6      
         15        SEND_VAR                                                 $6
         16        DO_ICALL                                                 
   14    17        INIT_FCALL                                               'var_dump'
         18        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         19        SEND_VAL_EX                                              <array>
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
         22        DO_ICALL                                                 
   15    23        INIT_FCALL                                               'var_dump'
         24        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         25        SEND_VAL_EX                                              <array>
         26        DO_FCALL                                      0  $10     
         27        SEND_VAR                                                 $10
         28        DO_ICALL                                                 
   17    29        INIT_FCALL                                               'var_dump'
         30        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         31        SEND_VAL_EX                                              <array>
         32        DO_FCALL                                      0  $12     
         33        SEND_VAR                                                 $12
         34        DO_ICALL                                                 
   18    35        INIT_FCALL                                               'var_dump'
         36        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         37        SEND_VAL_EX                                              <array>
         38        DO_FCALL                                      0  $14     
         39        SEND_VAR                                                 $14
         40        DO_ICALL                                                 
   19    41        INIT_FCALL                                               'var_dump'
         42        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         43        SEND_VAL_EX                                              <array>
         44        DO_FCALL                                      0  $16     
         45        SEND_VAR                                                 $16
         46        DO_ICALL                                                 
   20    47        INIT_FCALL                                               'var_dump'
         48        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         49        SEND_VAL_EX                                              <array>
         50        DO_FCALL                                      0  $18     
         51        SEND_VAR                                                 $18
         52        DO_ICALL                                                 
   21    53        INIT_FCALL                                               'var_dump'
         54        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         55        SEND_VAL_EX                                              <array>
         56        DO_FCALL                                      0  $20     
         57        SEND_VAR                                                 $20
         58        DO_ICALL                                                 
   22    59        INIT_FCALL                                               'var_dump'
         60        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         61        SEND_VAL_EX                                              <array>
         62        DO_FCALL                                      0  $22     
         63        SEND_VAR                                                 $22
         64        DO_ICALL                                                 
         65      > RETURN                                                   1

Function isindexedarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LO1PD
function name:  isIndexedArray
number of ops:  13
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'array_keys'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $1      
          5        SEND_VAR                                                 $1
          6        SEND_VAL                                                 'is_string'
          7        DO_ICALL                                         $2      
          8        COUNT                                            ~3      $2
          9        BOOL                                             ~4      ~3
         10        BOOL_NOT                                         ~5      ~4
         11      > RETURN                                                   ~5
    6    12*     > RETURN                                                   null

End of function isindexedarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.46 ms | 1403 KiB | 22 Q