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')); } $a3 = array_fill(1, 6, 0) + array(0); print_r($a3); 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/jEhUg
function name:  (null)
number of ops:  71
compiled vars:  !0 = $a3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'array_fill'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 6
          3        SEND_VAL                                                 0
          4        DO_ICALL                                         $1      
          5        ADD                                              ~2      $1, <array>
          6        ASSIGN                                                   !0, ~2
    9     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   11    10        INIT_FCALL                                               'var_dump'
         11        INIT_FCALL                                               'isindexedarray'
         12        SEND_VAL                                                 'a'
         13        DO_FCALL                                      0  $5      
         14        SEND_VAR                                                 $5
         15        DO_ICALL                                                 
   12    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         18        SEND_VAL_EX                                              <array>
         19        DO_FCALL                                      0  $7      
         20        SEND_VAR                                                 $7
         21        DO_ICALL                                                 
   13    22        INIT_FCALL                                               'var_dump'
         23        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         24        SEND_VAL_EX                                              <array>
         25        DO_FCALL                                      0  $9      
         26        SEND_VAR                                                 $9
         27        DO_ICALL                                                 
   14    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         30        SEND_VAL_EX                                              <array>
         31        DO_FCALL                                      0  $11     
         32        SEND_VAR                                                 $11
         33        DO_ICALL                                                 
   16    34        INIT_FCALL                                               'var_dump'
         35        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         36        SEND_VAL_EX                                              <array>
         37        DO_FCALL                                      0  $13     
         38        SEND_VAR                                                 $13
         39        DO_ICALL                                                 
   17    40        INIT_FCALL                                               'var_dump'
         41        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         42        SEND_VAL_EX                                              <array>
         43        DO_FCALL                                      0  $15     
         44        SEND_VAR                                                 $15
         45        DO_ICALL                                                 
   18    46        INIT_FCALL                                               'var_dump'
         47        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         48        SEND_VAL_EX                                              <array>
         49        DO_FCALL                                      0  $17     
         50        SEND_VAR                                                 $17
         51        DO_ICALL                                                 
   19    52        INIT_FCALL                                               'var_dump'
         53        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         54        SEND_VAL_EX                                              <array>
         55        DO_FCALL                                      0  $19     
         56        SEND_VAR                                                 $19
         57        DO_ICALL                                                 
   20    58        INIT_FCALL                                               'var_dump'
         59        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         60        SEND_VAL_EX                                              <array>
         61        DO_FCALL                                      0  $21     
         62        SEND_VAR                                                 $21
         63        DO_ICALL                                                 
   21    64        INIT_FCALL                                               'var_dump'
         65        INIT_FCALL_BY_NAME                                       'isSequentialArray'
         66        SEND_VAL_EX                                              <array>
         67        DO_FCALL                                      0  $23     
         68        SEND_VAR                                                 $23
         69        DO_ICALL                                                 
         70      > RETURN                                                   1

Function isindexedarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jEhUg
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:
283.77 ms | 1403 KiB | 25 Q