3v4l.org

run code in 500+ PHP versions simultaneously
<?php class ColumnKeyClass { function __toString() { return 'first_name'; } } class IndexKeyClass { function __toString() { return 'id'; } } class ValueClass { function __toString() { return '2135'; } } $column_key = new ColumnKeyClass(); $index_key = new IndexKeyClass(); $value = new ValueClass(); // Array representing a possible record set returned from a database $records = array( array( 'id' => $value, 'first_name' => 'John', 'last_name' => 'XXX' ), array( 'id' => 3245, 'first_name' => 'Sally', 'last_name' => 'Smith' ), ); var_dump($column_key); var_dump($index_key); var_dump($value); var_dump($records[0]['id']); $firstNames = array_column($records, $column_key, $index_key); print_r($firstNames); var_dump($column_key); var_dump($index_key); var_dump($value); var_dump($records[0]['id']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1uMqh
function name:  (null)
number of ops:  56
compiled vars:  !0 = $column_key, !1 = $index_key, !2 = $value, !3 = $records, !4 = $firstNames
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   DECLARE_CLASS                                                'columnkeyclass'
    6     1        DECLARE_CLASS                                                'indexkeyclass'
   10     2        DECLARE_CLASS                                                'valueclass'
   15     3        NEW                                                  $5      'ColumnKeyClass'
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !0, $5
   16     6        NEW                                                  $8      'IndexKeyClass'
          7        DO_FCALL                                          0          
          8        ASSIGN                                                       !1, $8
   17     9        NEW                                                  $11     'ValueClass'
         10        DO_FCALL                                          0          
         11        ASSIGN                                                       !2, $11
   23    12        INIT_ARRAY                                           ~14     !2, 'id'
   24    13        ADD_ARRAY_ELEMENT                                    ~14     'John', 'first_name'
   25    14        ADD_ARRAY_ELEMENT                                    ~14     'XXX', 'last_name'
         15        INIT_ARRAY                                           ~15     ~14
   23    16        ADD_ARRAY_ELEMENT                                    ~15     <array>
   21    17        ASSIGN                                                       !3, ~15
   34    18        INIT_FCALL                                                   'var_dump'
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                                     
   35    21        INIT_FCALL                                                   'var_dump'
         22        SEND_VAR                                                     !1
         23        DO_ICALL                                                     
   36    24        INIT_FCALL                                                   'var_dump'
         25        SEND_VAR                                                     !2
         26        DO_ICALL                                                     
   37    27        INIT_FCALL                                                   'var_dump'
         28        FETCH_DIM_R                                          ~20     !3, 0
         29        FETCH_DIM_R                                          ~21     ~20, 'id'
         30        SEND_VAL                                                     ~21
         31        DO_ICALL                                                     
   38    32        INIT_FCALL                                                   'array_column'
         33        SEND_VAR                                                     !3
         34        SEND_VAR                                                     !0
         35        SEND_VAR                                                     !1
         36        DO_ICALL                                             $23     
         37        ASSIGN                                                       !4, $23
   39    38        INIT_FCALL                                                   'print_r'
         39        SEND_VAR                                                     !4
         40        DO_ICALL                                                     
   40    41        INIT_FCALL                                                   'var_dump'
         42        SEND_VAR                                                     !0
         43        DO_ICALL                                                     
   41    44        INIT_FCALL                                                   'var_dump'
         45        SEND_VAR                                                     !1
         46        DO_ICALL                                                     
   42    47        INIT_FCALL                                                   'var_dump'
         48        SEND_VAR                                                     !2
         49        DO_ICALL                                                     
   43    50        INIT_FCALL                                                   'var_dump'
         51        FETCH_DIM_R                                          ~29     !3, 0
         52        FETCH_DIM_R                                          ~30     ~29, 'id'
         53        SEND_VAL                                                     ~30
         54        DO_ICALL                                                     
         55      > RETURN                                                       1

Class ColumnKeyClass:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1uMqh
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E > > RETURN                                                       'first_name'
          1*       VERIFY_RETURN_TYPE                                           
          2*     > RETURN                                                       null

End of function __tostring

End of class ColumnKeyClass.

Class IndexKeyClass:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1uMqh
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    7     0  E > > RETURN                                                       'id'
          1*       VERIFY_RETURN_TYPE                                           
          2*     > RETURN                                                       null

End of function __tostring

End of class IndexKeyClass.

Class ValueClass:
Function __tostring:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1uMqh
function name:  __toString
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                       '2135'
          1*       VERIFY_RETURN_TYPE                                           
          2*     > RETURN                                                       null

End of function __tostring

End of class ValueClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.69 ms | 485 KiB | 10 Q