3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = <<<'JSON' [ { "code": "AF", "total": 1 }, { "code": "DZ", "total": 1 }, { "code": "AS", "total": 2 } ] JSON; $array = json_decode($json, true); function compoundArray(Array $array, $key, $value) { return array_column($array, $key, $value); } var_dump(compoundArray($array, 'total', 'code'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FHn4H
function name:  (null)
number of ops:  15
compiled vars:  !0 = $json, !1 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A%7B%0A%22code%22%3A+%22AF%22%2C%0A%22total%22%3A+1%0A%7D%2C%0A%7B%0A%22code%22%3A+%22DZ%22%2C%0A%22total%22%3A+1%0A%7D%2C%0A%7B%0A%22code%22%3A+%22AS%22%2C%0A%22total%22%3A+2%0A%7D%0A%5D'
   20     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
   27     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'compoundarray'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'total'
         10        SEND_VAL                                                 'code'
         11        DO_FCALL                                      0  $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function compoundarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FHn4H
function name:  compoundArray
number of ops:  10
compiled vars:  !0 = $array, !1 = $key, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   24     3        INIT_FCALL                                               'array_column'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        SEND_VAR                                                 !2
          7        DO_ICALL                                         $3      
          8      > RETURN                                                   $3
   25     9*     > RETURN                                                   null

End of function compoundarray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.78 ms | 1006 KiB | 17 Q