3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_column1($input = null, $columnKey = null, $indexKey = null) { switch (func_num_args()) { case 0: trigger_error('array_column() expects at least 2 parameters, 0 given', E_USER_WARNING); return null; case 1: trigger_error('array_column() expects at least 2 parameters, 1 given', E_USER_WARNING); return null; } if (!is_array($input)) { trigger_error('array_column() expects parameter 1 to be array, ' . gettype($input) . ' given', E_USER_WARNING); return null; } if (null !== $columnKey && !is_int($columnKey) && !is_string($columnKey) && !(is_object($columnKey) && method_exists($columnKey, '__toString')) ) { trigger_error('array_column(): The column key should be either a string or an integer', E_USER_WARNING); return false; } if (isset($indexKey) && !is_int($indexKey) && !is_string($indexKey) && !(is_object($indexKey) && method_exists($indexKey, '__toString')) ) { trigger_error('array_column(): The index key should be either a string or an integer', E_USER_WARNING); return false; } $resultArray = array(); foreach ($input as $row) { $key = $value = null; $keySet = $valueSet = false; if ($indexKey !== null && array_key_exists($indexKey, $row)) { $keySet = true; $key = $row[$indexKey]; } if (is_array($row)) { if (null === $columnKey) { $valueSet = true; $value = $row; } elseif (array_key_exists($columnKey, $row)) { $valueSet = true; $value = $row[$columnKey]; } } if ($valueSet) { if ($keySet) { $resultArray[$key] = $value; } else { $resultArray[] = $value; } } } return $resultArray; } var_dump( array_column1( array( array( 'a' => null, 'b' => 16, ), ), 'a' ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gg8cX
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   74     0  E >   INIT_FCALL                                               'var_dump'
   75     1        INIT_FCALL                                               'array_column1'
   78     2        SEND_VAL                                                 <array>
   82     3        SEND_VAL                                                 'a'
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   84     7      > RETURN                                                   1

Function array_column1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 44) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
2 jumps found. (Code = 44) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 33
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 38
Branch analysis from position: 35
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 42
Branch analysis from position: 39
2 jumps found. (Code = 46) Position 1 = 43, Position 2 = 52
Branch analysis from position: 43
2 jumps found. (Code = 46) Position 1 = 45, Position 2 = 50
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 53, Position 2 = 58
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
2 jumps found. (Code = 46) Position 1 = 60, Position 2 = 63
Branch analysis from position: 60
2 jumps found. (Code = 46) Position 1 = 64, Position 2 = 67
Branch analysis from position: 64
2 jumps found. (Code = 46) Position 1 = 68, Position 2 = 77
Branch analysis from position: 68
2 jumps found. (Code = 46) Position 1 = 70, Position 2 = 75
Branch analysis from position: 70
2 jumps found. (Code = 43) Position 1 = 78, Position 2 = 83
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 83
2 jumps found. (Code = 77) Position 1 = 85, Position 2 = 118
Branch analysis from position: 85
2 jumps found. (Code = 78) Position 1 = 86, Position 2 = 118
Branch analysis from position: 86
2 jumps found. (Code = 46) Position 1 = 92, Position 2 = 94
Branch analysis from position: 92
2 jumps found. (Code = 43) Position 1 = 95, Position 2 = 98
Branch analysis from position: 95
2 jumps found. (Code = 43) Position 1 = 100, Position 2 = 110
Branch analysis from position: 100
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 105
Branch analysis from position: 102
1 jumps found. (Code = 42) Position 1 = 110
Branch analysis from position: 110
2 jumps found. (Code = 43) Position 1 = 111, Position 2 = 117
Branch analysis from position: 111
2 jumps found. (Code = 43) Position 1 = 112, Position 2 = 115
Branch analysis from position: 112
1 jumps found. (Code = 42) Position 1 = 117
Branch analysis from position: 117
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 115
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
Branch analysis from position: 117
Branch analysis from position: 105
2 jumps found. (Code = 43) Position 1 = 107, Position 2 = 110
Branch analysis from position: 107
2 jumps found. (Code = 43) Position 1 = 111, Position 2 = 117
Branch analysis from position: 111
Branch analysis from position: 117
Branch analysis from position: 110
Branch analysis from position: 110
Branch analysis from position: 98
Branch analysis from position: 94
Branch analysis from position: 118
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 118
Branch analysis from position: 75
Branch analysis from position: 77
Branch analysis from position: 67
Branch analysis from position: 63
Branch analysis from position: 50
Branch analysis from position: 52
Branch analysis from position: 42
Branch analysis from position: 38
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gg8cX
function name:  array_column1
number of ops:  121
compiled vars:  !0 = $input, !1 = $columnKey, !2 = $indexKey, !3 = $resultArray, !4 = $row, !5 = $key, !6 = $value, !7 = $keySet, !8 = $valueSet
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
    5     3        FUNC_NUM_ARGS                                    ~9      
    6     4        CASE                                                     ~9, 0
          5      > JMPNZ                                                    ~10, ->9
   10     6    >   CASE                                                     ~9, 1
          7      > JMPNZ                                                    ~10, ->15
          8    > > JMP                                                      ->21
    7     9    >   INIT_FCALL                                               'trigger_error'
         10        SEND_VAL                                                 'array_column%28%29+expects+at+least+2+parameters%2C+0+given'
         11        SEND_VAL                                                 512
         12        DO_ICALL                                                 
    8    13        FREE                                                     ~9
         14      > RETURN                                                   null
   11    15    >   INIT_FCALL                                               'trigger_error'
         16        SEND_VAL                                                 'array_column%28%29+expects+at+least+2+parameters%2C+1+given'
         17        SEND_VAL                                                 512
         18        DO_ICALL                                                 
   12    19        FREE                                                     ~9
         20      > RETURN                                                   null
         21    >   FREE                                                     ~9
   15    22        TYPE_CHECK                                  128  ~13     !0
         23        BOOL_NOT                                         ~14     ~13
         24      > JMPZ                                                     ~14, ->33
   16    25    >   INIT_FCALL                                               'trigger_error'
         26        GET_TYPE                                         ~15     !0
         27        CONCAT                                           ~16     'array_column%28%29+expects+parameter+1+to+be+array%2C+', ~15
         28        CONCAT                                           ~17     ~16, '+given'
         29        SEND_VAL                                                 ~17
         30        SEND_VAL                                                 512
         31        DO_ICALL                                                 
   17    32      > RETURN                                                   null
   20    33    >   TYPE_CHECK                                  1020  ~19     !1
         34      > JMPZ_EX                                          ~19     ~19, ->38
   21    35    >   TYPE_CHECK                                   16  ~20     !1
         36        BOOL_NOT                                         ~21     ~20
         37        BOOL                                             ~19     ~21
         38    > > JMPZ_EX                                          ~19     ~19, ->42
   22    39    >   TYPE_CHECK                                   64  ~22     !1
         40        BOOL_NOT                                         ~23     ~22
         41        BOOL                                             ~19     ~23
         42    > > JMPZ_EX                                          ~19     ~19, ->52
   23    43    >   TYPE_CHECK                                  256  ~24     !1
         44      > JMPZ_EX                                          ~24     ~24, ->50
         45    >   INIT_FCALL                                               'method_exists'
         46        SEND_VAR                                                 !1
         47        SEND_VAL                                                 '__toString'
         48        DO_ICALL                                         $25     
         49        BOOL                                             ~24     $25
         50    >   BOOL_NOT                                         ~26     ~24
         51        BOOL                                             ~19     ~26
         52    > > JMPZ                                                     ~19, ->58
   25    53    >   INIT_FCALL                                               'trigger_error'
         54        SEND_VAL                                                 'array_column%28%29%3A+The+column+key+should+be+either+a+string+or+an+integer'
         55        SEND_VAL                                                 512
         56        DO_ICALL                                                 
   26    57      > RETURN                                                   <false>
   29    58    >   ISSET_ISEMPTY_CV                                 ~28     !2
         59      > JMPZ_EX                                          ~28     ~28, ->63
   30    60    >   TYPE_CHECK                                   16  ~29     !2
         61        BOOL_NOT                                         ~30     ~29
         62        BOOL                                             ~28     ~30
         63    > > JMPZ_EX                                          ~28     ~28, ->67
   31    64    >   TYPE_CHECK                                   64  ~31     !2
         65        BOOL_NOT                                         ~32     ~31
         66        BOOL                                             ~28     ~32
         67    > > JMPZ_EX                                          ~28     ~28, ->77
   32    68    >   TYPE_CHECK                                  256  ~33     !2
         69      > JMPZ_EX                                          ~33     ~33, ->75
         70    >   INIT_FCALL                                               'method_exists'
         71        SEND_VAR                                                 !2
         72        SEND_VAL                                                 '__toString'
         73        DO_ICALL                                         $34     
         74        BOOL                                             ~33     $34
         75    >   BOOL_NOT                                         ~35     ~33
         76        BOOL                                             ~28     ~35
         77    > > JMPZ                                                     ~28, ->83
   34    78    >   INIT_FCALL                                               'trigger_error'
         79        SEND_VAL                                                 'array_column%28%29%3A+The+index+key+should+be+either+a+string+or+an+integer'
         80        SEND_VAL                                                 512
         81        DO_ICALL                                                 
   35    82      > RETURN                                                   <false>
   38    83    >   ASSIGN                                                   !3, <array>
   40    84      > FE_RESET_R                                       $38     !0, ->118
         85    > > FE_FETCH_R                                               $38, !4, ->118
   42    86    >   ASSIGN                                           ~39     !6, null
         87        ASSIGN                                                   !5, ~39
   43    88        ASSIGN                                           ~41     !8, <false>
         89        ASSIGN                                                   !7, ~41
   45    90        TYPE_CHECK                                  1020  ~43     !2
         91      > JMPZ_EX                                          ~43     ~43, ->94
         92    >   ARRAY_KEY_EXISTS                                 ~44     !2, !4
         93        BOOL                                             ~43     ~44
         94    > > JMPZ                                                     ~43, ->98
   46    95    >   ASSIGN                                                   !7, <true>
   47    96        FETCH_DIM_R                                      ~46     !4, !2
         97        ASSIGN                                                   !5, ~46
   50    98    >   TYPE_CHECK                                  128          !4
         99      > JMPZ                                                     ~48, ->110
   51   100    >   TYPE_CHECK                                    2          !1
        101      > JMPZ                                                     ~49, ->105
   52   102    >   ASSIGN                                                   !8, <true>
   53   103        ASSIGN                                                   !6, !4
        104      > JMP                                                      ->110
   54   105    >   ARRAY_KEY_EXISTS                                         !1, !4
        106      > JMPZ                                                     ~52, ->110
   55   107    >   ASSIGN                                                   !8, <true>
   56   108        FETCH_DIM_R                                      ~54     !4, !1
        109        ASSIGN                                                   !6, ~54
   60   110    > > JMPZ                                                     !8, ->117
   61   111    > > JMPZ                                                     !7, ->115
   62   112    >   ASSIGN_DIM                                               !3, !5
        113        OP_DATA                                                  !6
        114      > JMP                                                      ->117
   64   115    >   ASSIGN_DIM                                               !3
        116        OP_DATA                                                  !6
   40   117    > > JMP                                                      ->85
        118    >   FE_FREE                                                  $38
   70   119      > RETURN                                                   !3
   71   120*     > RETURN                                                   null

End of function array_column1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.35 ms | 1410 KiB | 20 Q