3v4l.org

run code in 300+ PHP versions simultaneously
<?php $oldArr = [ ['sno' => 'q3', 'result' => '15'], ['sno' => 'q1', 'result' => '5'], ['sno' => 'q2', 'result' => '10'] ]; $newArr = array_reduce($oldArr, function($carry, $item){ $carry[$item["sno"]] = $item["result"]; return $carry; }); var_dump($newArr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aoTF
function name:  (null)
number of ops:  11
compiled vars:  !0 = $oldArr, !1 = $newArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'array_reduce'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
   11     4        SEND_VAL                                                 ~3
    8     5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !1, $4
   12     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
         10      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0aoTF
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $carry, !1 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        FETCH_DIM_R                                      ~2      !1, 'sno'
          3        FETCH_DIM_R                                      ~4      !1, 'result'
          4        ASSIGN_DIM                                               !0, ~2
          5        OP_DATA                                                  ~4
   10     6      > RETURN                                                   !0
   11     7*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.35 ms | 998 KiB | 15 Q