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

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