3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array('amount'=>100,'date'=>'2014-03-29'), array('amount'=>200,'date'=>'2014-03-31'), array('amount'=>120,'date'=>'2014-03-30'), ); $total = 0; //以日期递增排序 uasort($arr, function($a, $b) { return strtotime($a['date']) - strtotime($b['date']); }); array_walk_recursive($arr, function(&$val, $key) use (&$total) { if ($key === 'amount') { $total += $val; $val = $total; } });var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pShio
function name:  (null)
number of ops:  17
compiled vars:  !0 = $arr, !1 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 0
   11     2        INIT_FCALL                                               'uasort'
          3        SEND_REF                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpShio%3A11%240'
   13     5        SEND_VAL                                                 ~4
          6        DO_ICALL                                                 
   15     7        INIT_FCALL                                               'array_walk_recursive'
          8        SEND_REF                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FpShio%3A15%241'
         10        BIND_LEXICAL                                             ~6, !1
   20    11        SEND_VAL                                                 ~6
         12        DO_ICALL                                                 
         13        INIT_FCALL                                               'var_dump'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FpShio%3A11%240

Function %00%7Bclosure%7D%2Fin%2FpShio%3A15%241:
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
filename:       /in/pShio
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $val, !1 = $key, !2 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   16     3        IS_IDENTICAL                                             !1, 'amount'
          4      > JMPZ                                                     ~3, ->7
   17     5    >   ASSIGN_OP                                     1          !2, !0
   18     6        ASSIGN                                                   !0, !2
   20     7    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FpShio%3A15%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.33 ms | 1400 KiB | 21 Q