3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array( array('amount'=>100,'date'=>'2014-03-29'), array('amount'=>120,'date'=>'2014-03-30'), array('amount'=>200,'date'=>'2014-03-31'), array('amount'=>0,'date'=>'2014-04-31'), array('amount'=>0,'date'=>'2014-05-31') ); function sd($a,$b) {if($a['date'] == $b['date']) return 0; return $a['date'] >$b['date'] ? 1 : -1;} usort($arr, 'sd'); $amount = 0; foreach($arr as &$item) { $amount += $item['amount']; $item['amount'] = $amount; } print_r($arr); $arr =array(100,100,100,15,20,50,70,100,100,);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
2 jumps found. (Code = 126) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/nQcDS
function name:  (null)
number of ops:  19
compiled vars:  !0 = $arr, !1 = $amount, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 'sd'
          4        DO_ICALL                                                 
   14     5        ASSIGN                                                   !1, 0
   15     6      > FE_RESET_RW                                      $6      !0, ->13
          7    > > FE_FETCH_RW                                              $6, !2, ->13
   16     8    >   FETCH_DIM_R                                      ~7      !2, 'amount'
          9        ASSIGN_OP                                     1          !1, ~7
   17    10        ASSIGN_DIM                                               !2, 'amount'
         11        OP_DATA                                                  !1
   15    12      > JMP                                                      ->7
         13    >   FE_FREE                                                  $6
   19    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                                 
   23    17        ASSIGN                                                   !0, <array>
         18      > RETURN                                                   1

Function sd:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nQcDS
function name:  sd
number of ops:  16
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !0, 'date'
          3        FETCH_DIM_R                                      ~3      !1, 'date'
          4        IS_EQUAL                                                 ~2, ~3
          5      > JMPZ                                                     ~4, ->7
          6    > > RETURN                                                   0
          7    >   FETCH_DIM_R                                      ~5      !0, 'date'
          8        FETCH_DIM_R                                      ~6      !1, 'date'
          9        IS_SMALLER                                               ~6, ~5
         10      > JMPZ                                                     ~7, ->13
         11    >   QM_ASSIGN                                        ~8      1
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      -1
         14    > > RETURN                                                   ~8
         15*     > RETURN                                                   null

End of function sd

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.72 ms | 1400 KiB | 17 Q