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

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