3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!function_exists('is_assoc')){ function is_assoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); } } /** * 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) { if(is_assoc($data)){ return $data; }else{ return (array)call_user_func_array('array_merge_recursive',$data); } } $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') ) ); $b = getCols($a); var_dump($b);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 6
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/cEdhJ
function name:  (null)
number of ops:  43
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'function_exists'
          1        SEND_VAL                                                 'is_assoc'
          2        DO_ICALL                                         $2      
          3        BOOL_NOT                                         ~3      $2
          4      > JMPZ                                                     ~3, ->6
    5     5    >   DECLARE_FUNCTION                                         'is_assoc'
   35     6    >   INIT_ARRAY                                       ~4      1, 'id'
   36     7        ADD_ARRAY_ELEMENT                                ~4      'foo', 'name'
   37     8        INIT_FCALL                                               'date'
          9        SEND_VAL                                                 'm-d-Y'
         10        DO_ICALL                                         $5      
         11        ADD_ARRAY_ELEMENT                                ~4      $5, 'date'
         12        INIT_ARRAY                                       ~6      ~4
   39    13        INIT_ARRAY                                       ~7      2, 'id'
   40    14        ADD_ARRAY_ELEMENT                                ~7      'bar', 'name'
   41    15        INIT_FCALL                                               'date'
         16        SEND_VAL                                                 'm-d-Y'
         17        DO_ICALL                                         $8      
         18        ADD_ARRAY_ELEMENT                                ~7      $8, 'date'
         19        ADD_ARRAY_ELEMENT                                ~6      ~7
   43    20        INIT_ARRAY                                       ~9      3, 'id'
   44    21        ADD_ARRAY_ELEMENT                                ~9      'george', 'name'
   45    22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'm-d-Y'
         24        DO_ICALL                                         $10     
         25        ADD_ARRAY_ELEMENT                                ~9      $10, 'date'
         26        ADD_ARRAY_ELEMENT                                ~6      ~9
   47    27        INIT_ARRAY                                       ~11     4, 'id'
   48    28        ADD_ARRAY_ELEMENT                                ~11     'burdell', 'name'
   49    29        INIT_FCALL                                               'date'
         30        SEND_VAL                                                 'm-d-Y'
         31        DO_ICALL                                         $12     
         32        ADD_ARRAY_ELEMENT                                ~11     $12, 'date'
         33        ADD_ARRAY_ELEMENT                                ~6      ~11
   33    34        ASSIGN                                                   !0, ~6
   54    35        INIT_FCALL                                               'getcols'
         36        SEND_VAR                                                 !0
         37        DO_FCALL                                      0  $14     
         38        ASSIGN                                                   !1, $14
   56    39        INIT_FCALL                                               'var_dump'
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Function %00is_assoc%2Fin%2FcEdhJ%3A5%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cEdhJ
function name:  is_assoc
number of ops:  12
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     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      > RETURN                                                   ~4
    7    11*     > RETURN                                                   null

End of function %00is_assoc%2Fin%2FcEdhJ%3A5%240

Function getcols:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cEdhJ
function name:  getCols
number of ops:  14
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   23     1        INIT_FCALL_BY_NAME                                       'is_assoc'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $1      
          4      > JMPZ                                                     $1, ->7
   24     5    > > RETURN                                                   !0
          6*       JMP                                                      ->13
   26     7    >   INIT_FCALL                                               'array_merge_recursive'
          8        SEND_ARRAY                                               !0
          9        CHECK_UNDEF_ARGS                                         
         10        DO_FCALL                                      0  $2      
         11        CAST                                          7  ~3      $2
         12      > RETURN                                                   ~3
   28    13*     > RETURN                                                   null

End of function getcols

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.9 ms | 1403 KiB | 26 Q