3v4l.org

run code in 300+ PHP versions simultaneously
<?php $foo = ARRAY(); $foo[0] = ARRAY('key'=>'key0', 'value'=>'value0', 'text'=>'text0', 'int'=>1000); $foo[1] = ARRAY('key'=>'key1', 'value'=>'value1', 'text'=>'text1', 'int'=>1001); $foo[2] = ARRAY('key'=>'key2', 'value'=>'value2', 'text'=>'text2', 'int'=>1002); $foo[3] = ARRAY('key'=>'key3', 'value'=>'value3', 'text'=>'text3', 'int'=>1003); $foo[5] = ARRAY('key'=>'key5', 'value'=>'value5', 'text'=>'text5', 'int'=>1005); $foo[7] = ARRAY('key'=>'key7', 'value'=>'value7', 'text'=>'text7', 'int'=>1007); // reset indexes, set column 'value' as values $result1 = ArrayColumn($foo, 'value'); var_export($result1); print "\n\n"; // re-index with column 'key', use column 'value' as values $result2 = ArrayColumn($foo, 'value', 'key'); var_export($result2); print "\n\n"; // re-index with column 'int', use column 'value' as values $result3 = ArrayColumn($foo, 'value', 'int'); var_export($result3); print "\n\n"; // re-index with column 'int', use COMPLETE ARRAY as values $result4 = ArrayColumn($foo, NULL, 'int'); var_export($result4); print "\n\n"; function ArrayColumn($arr=FALSE, $column_value=FALSE, $column_index=FALSE, $unique=FALSE) { $arr = array_column($arr, $column_value, $column_index); if ($unique === TRUE) { $arr = array_unique($arr); } return $arr; } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f8VRn
function name:  (null)
number of ops:  53
compiled vars:  !0 = $foo, !1 = $result1, !2 = $result2, !3 = $result3, !4 = $result4
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN_DIM                                               !0, 0
          2        OP_DATA                                                  <array>
    6     3        ASSIGN_DIM                                               !0, 1
          4        OP_DATA                                                  <array>
    7     5        ASSIGN_DIM                                               !0, 2
          6        OP_DATA                                                  <array>
    8     7        ASSIGN_DIM                                               !0, 3
          8        OP_DATA                                                  <array>
    9     9        ASSIGN_DIM                                               !0, 5
         10        OP_DATA                                                  <array>
   10    11        ASSIGN_DIM                                               !0, 7
         12        OP_DATA                                                  <array>
   13    13        INIT_FCALL_BY_NAME                                       'ArrayColumn'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAL_EX                                              'value'
         16        DO_FCALL                                      0  $12     
         17        ASSIGN                                                   !1, $12
   14    18        INIT_FCALL                                               'var_export'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                                 
         21        ECHO                                                     '%0A%0A'
   17    22        INIT_FCALL_BY_NAME                                       'ArrayColumn'
         23        SEND_VAR_EX                                              !0
         24        SEND_VAL_EX                                              'value'
         25        SEND_VAL_EX                                              'key'
         26        DO_FCALL                                      0  $15     
         27        ASSIGN                                                   !2, $15
   18    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
         31        ECHO                                                     '%0A%0A'
   21    32        INIT_FCALL_BY_NAME                                       'ArrayColumn'
         33        SEND_VAR_EX                                              !0
         34        SEND_VAL_EX                                              'value'
         35        SEND_VAL_EX                                              'int'
         36        DO_FCALL                                      0  $18     
         37        ASSIGN                                                   !3, $18
   22    38        INIT_FCALL                                               'var_export'
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                                 
         41        ECHO                                                     '%0A%0A'
   25    42        INIT_FCALL_BY_NAME                                       'ArrayColumn'
         43        SEND_VAR_EX                                              !0
         44        SEND_VAL_EX                                              null
         45        SEND_VAL_EX                                              'int'
         46        DO_FCALL                                      0  $21     
         47        ASSIGN                                                   !4, $21
   26    48        INIT_FCALL                                               'var_export'
         49        SEND_VAR                                                 !4
         50        DO_ICALL                                                 
         51        ECHO                                                     '%0A%0A'
   34    52      > RETURN                                                   1

Function arraycolumn:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/f8VRn
function name:  ArrayColumn
number of ops:  18
compiled vars:  !0 = $arr, !1 = $column_value, !2 = $column_index, !3 = $unique
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV_INIT                                        !0      <false>
          1        RECV_INIT                                        !1      <false>
          2        RECV_INIT                                        !2      <false>
          3        RECV_INIT                                        !3      <false>
   30     4        INIT_FCALL                                               'array_column'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        SEND_VAR                                                 !2
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !0, $4
   31    10        TYPE_CHECK                                    8          !3
         11      > JMPZ                                                     ~6, ->16
         12    >   INIT_FCALL                                               'array_unique'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $7      
         15        ASSIGN                                                   !0, $7
   32    16    > > RETURN                                                   !0
   33    17*     > RETURN                                                   null

End of function arraycolumn

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.89 ms | 1400 KiB | 19 Q