3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * getCols * * Takes an array of associative arrays and combines them to get * the columns * * @author Joe Richardson * @access public * @return object Instance of DB or Null */ function getCols(array $data, $col = NULL) { $d = (array)call_user_func_array('array_merge_recursive',$data); return ($col === NULL)?$d:$d[$col]; } $a = array( array( 'id' => 1 , 'name' => 'foo' , 'date' => date('m-d-Y') ) , array( 'id' => 2 , 'name' => 'bar' , 'date' => date('m-d-Y') ) , array( 'id' => 3 , 'name' => 'george' , 'date' => date('m-d-Y') ) , array( 'id' => 4 , 'name' => 'burdell' , 'date' => date('m-d-Y') ) ); if(function_exists('array_column')) { echo('array_column '); $b = array_columns($a, 'name'); }else { echo('getCols '); $b = getCols($a, 'name'); } var_dump($b);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 40
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CNPkt
function name:  (null)
number of ops:  50
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   INIT_ARRAY                                       ~2      1, 'id'
   29     1        ADD_ARRAY_ELEMENT                                ~2      'foo', 'name'
   30     2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'm-d-Y'
          4        DO_ICALL                                         $3      
          5        ADD_ARRAY_ELEMENT                                ~2      $3, 'date'
          6        INIT_ARRAY                                       ~4      ~2
   32     7        INIT_ARRAY                                       ~5      2, 'id'
   33     8        ADD_ARRAY_ELEMENT                                ~5      'bar', 'name'
   34     9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'm-d-Y'
         11        DO_ICALL                                         $6      
         12        ADD_ARRAY_ELEMENT                                ~5      $6, 'date'
         13        ADD_ARRAY_ELEMENT                                ~4      ~5
   36    14        INIT_ARRAY                                       ~7      3, 'id'
   37    15        ADD_ARRAY_ELEMENT                                ~7      'george', 'name'
   38    16        INIT_FCALL                                               'date'
         17        SEND_VAL                                                 'm-d-Y'
         18        DO_ICALL                                         $8      
         19        ADD_ARRAY_ELEMENT                                ~7      $8, 'date'
         20        ADD_ARRAY_ELEMENT                                ~4      ~7
   40    21        INIT_ARRAY                                       ~9      4, 'id'
   41    22        ADD_ARRAY_ELEMENT                                ~9      'burdell', 'name'
   42    23        INIT_FCALL                                               'date'
         24        SEND_VAL                                                 'm-d-Y'
         25        DO_ICALL                                         $10     
         26        ADD_ARRAY_ELEMENT                                ~9      $10, 'date'
         27        ADD_ARRAY_ELEMENT                                ~4      ~9
   26    28        ASSIGN                                                   !0, ~4
   47    29        INIT_FCALL                                               'function_exists'
         30        SEND_VAL                                                 'array_column'
         31        DO_ICALL                                         $12     
         32      > JMPZ                                                     $12, ->40
   49    33    >   ECHO                                                     'array_column+'
   50    34        INIT_FCALL_BY_NAME                                       'array_columns'
         35        SEND_VAR_EX                                              !0
         36        SEND_VAL_EX                                              'name'
         37        DO_FCALL                                      0  $13     
         38        ASSIGN                                                   !1, $13
         39      > JMP                                                      ->46
   54    40    >   ECHO                                                     'getCols+'
   55    41        INIT_FCALL                                               'getcols'
         42        SEND_VAR                                                 !0
         43        SEND_VAL                                                 'name'
         44        DO_FCALL                                      0  $15     
         45        ASSIGN                                                   !1, $15
   58    46    >   INIT_FCALL                                               'var_dump'
         47        SEND_VAR                                                 !1
         48        DO_ICALL                                                 
         49      > RETURN                                                   1

Function getcols:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CNPkt
function name:  getCols
number of ops:  16
compiled vars:  !0 = $data, !1 = $col, !2 = $d
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
   18     2        INIT_FCALL                                               'array_merge_recursive'
          3        SEND_ARRAY                                               !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      0  $3      
          6        CAST                                          7  ~4      $3
          7        ASSIGN                                                   !2, ~4
   20     8        TYPE_CHECK                                    2          !1
          9      > JMPZ                                                     ~6, ->12
         10    >   QM_ASSIGN                                        ~7      !2
         11      > JMP                                                      ->14
         12    >   FETCH_DIM_R                                      ~8      !2, !1
         13        QM_ASSIGN                                        ~7      ~8
         14    > > RETURN                                                   ~7
   21    15*     > RETURN                                                   null

End of function getcols

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
187.14 ms | 1394 KiB | 22 Q