3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => [ "model_id" => 1, "price" => 2000, ], 1 => [ "model_id" => 2, "price" => 3000, ], 2 => [ "model_id" => 1, "price" => 1500, ], ]; function array_column1($input, $column_key = null, $index_key = null) { $result = []; $i = 0; foreach ($input as $v) { $k = $index_key === null || !isset($v[$index_key]) ? $i++ : $v[$index_key]; $result[$k][] = $column_key === null ? $v : (isset($v[$column_key]) ? $v[$column_key] : null); } $result = array_map("min", $result); return $result; } $temp = array_column1($arr, 'price', 'model_id'); print_r($temp);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AnE56
function name:  (null)
number of ops:  11
compiled vars:  !0 = $arr, !1 = $temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'array_column1'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'price'
          4        SEND_VAL                                                 'model_id'
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !1, $3
   28     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function array_column1:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 34
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 34
Branch analysis from position: 7
2 jumps found. (Code = 47) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
Branch analysis from position: 23
Branch analysis from position: 12
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/AnE56
function name:  array_column1
number of ops:  42
compiled vars:  !0 = $input, !1 = $column_key, !2 = $index_key, !3 = $result, !4 = $i, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
   18     3        ASSIGN                                                   !3, <array>
   19     4        ASSIGN                                                   !4, 0
   20     5      > FE_RESET_R                                       $9      !0, ->34
          6    > > FE_FETCH_R                                               $9, !5, ->34
   21     7    >   TYPE_CHECK                                    2  ~10     !2
          8      > JMPNZ_EX                                         ~10     ~10, ->12
          9    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~11     !5, !2
         10        BOOL_NOT                                         ~12     ~11
         11        BOOL                                             ~10     ~12
         12    > > JMPZ                                                     ~10, ->16
         13    >   POST_INC                                         ~13     !4
         14        QM_ASSIGN                                        ~14     ~13
         15      > JMP                                                      ->18
         16    >   FETCH_DIM_R                                      ~15     !5, !2
         17        QM_ASSIGN                                        ~14     ~15
         18    >   ASSIGN                                                   !6, ~14
   22    19        TYPE_CHECK                                    2          !1
         20      > JMPZ                                                     ~19, ->23
         21    >   QM_ASSIGN                                        ~20     !5
         22      > JMP                                                      ->30
         23    >   ISSET_ISEMPTY_DIM_OBJ                         0          !5, !1
         24      > JMPZ                                                     ~21, ->28
         25    >   FETCH_DIM_R                                      ~22     !5, !1
         26        QM_ASSIGN                                        ~23     ~22
         27      > JMP                                                      ->29
         28    >   QM_ASSIGN                                        ~23     null
         29    >   QM_ASSIGN                                        ~20     ~23
         30    >   FETCH_DIM_W                                      $17     !3, !6
         31        ASSIGN_DIM                                               $17
         32        OP_DATA                                                  ~20
   20    33      > JMP                                                      ->6
         34    >   FE_FREE                                                  $9
   24    35        INIT_FCALL                                               'array_map'
         36        SEND_VAL                                                 'min'
         37        SEND_VAR                                                 !3
         38        DO_ICALL                                         $24     
         39        ASSIGN                                                   !3, $24
   25    40      > RETURN                                                   !3
   26    41*     > RETURN                                                   null

End of function array_column1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.96 ms | 1019 KiB | 16 Q