3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = json_encode(array('sleep' => 123)); $b = json_encode(array('sleep' => 987)); $logs = array(array('date' => '2014-01-01', 'data' => $a), array('date' => '2015-01-01', 'data' => $b)); $result = array_reduce($logs, function ($cur, $x) { $data = json_decode($x['data']); $cur[$x['date']] = $data->{'sleep'}; return $cur; }, array()); var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aWXiT
function name:  (null)
number of ops:  26
compiled vars:  !0 = $a, !1 = $b, !2 = $logs, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'json_encode'
          1        SEND_VAL                                                 <array>
          2        DO_ICALL                                         $4      
          3        ASSIGN                                                   !0, $4
    3     4        INIT_FCALL                                               'json_encode'
          5        SEND_VAL                                                 <array>
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !1, $6
    4     8        INIT_ARRAY                                       ~8      '2014-01-01', 'date'
          9        ADD_ARRAY_ELEMENT                                ~8      !0, 'data'
         10        INIT_ARRAY                                       ~9      ~8
         11        INIT_ARRAY                                       ~10     '2015-01-01', 'date'
         12        ADD_ARRAY_ELEMENT                                ~10     !1, 'data'
         13        ADD_ARRAY_ELEMENT                                ~9      ~10
         14        ASSIGN                                                   !2, ~9
    6    15        INIT_FCALL                                               'array_reduce'
         16        SEND_VAR                                                 !2
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaWXiT%3A6%240'
   11    18        SEND_VAL                                                 ~12
         19        SEND_VAL                                                 <array>
         20        DO_ICALL                                         $13     
    6    21        ASSIGN                                                   !3, $13
   13    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !3
         24        DO_ICALL                                                 
         25      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaWXiT%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aWXiT
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $cur, !1 = $x, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INIT_FCALL                                               'json_decode'
          3        FETCH_DIM_R                                      ~3      !1, 'data'
          4        SEND_VAL                                                 ~3
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !2, $4
    9     7        FETCH_DIM_R                                      ~6      !1, 'date'
          8        FETCH_OBJ_R                                      ~8      !2, 'sleep'
          9        ASSIGN_DIM                                               !0, ~6
         10        OP_DATA                                                  ~8
   10    11      > RETURN                                                   !0
   11    12*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaWXiT%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.97 ms | 1400 KiB | 21 Q