3v4l.org

run code in 300+ PHP versions simultaneously
<?php $facturation = [ 'start_time' => '27/06/2017', 'mtt' => '50000', 'periodicite' => '12' ]; var_dump(date('Y-m-d H:i:s', strtotime(str_replace('/', '-', $facturation['start_time'])))); die; // generate tasks depending on amount (/x days + rest in last // start_time and end_time accordingly $tasks_data = []; $current_start_time = date('Y-m-d', strtotime(str_replace('/', '-', $facturation['start_time']))); // calculate mtt per month approximately $mtt_per_period = floatval($facturation['mtt']) / floatval($facturation['periodicite']); $mtt_per_period = number_format((float)$mtt_per_period, 2, '.', ''); $delta_time = ($facturation['periodicite'] == '12') ? '1 month' : '1 year'; for ($i=0; $i < $facturation['periodicite'] ; $i++) { $current_end_time = date('d/m/Y', strtotime($current_start_time . ' +' . $delta_time)); $budget = $mtt_per_period; if ($i === intval($facturation['periodicite'])-1) { $budget = floatval($facturation['mtt']) - ((floatval($facturation['periodicite'])-1) * $mtt_per_period); $budget = number_format((float)$budget, 2, '.', ''); } $tasks_data[] = [ 'start_time' => $current_start_time, 'end_time' => $current_end_time, 'title' => ($facturation['periodicite'] == '12') ? 'acompte ' . '' . explode('/', $current_start_time)[2] : 'échéance unique', 'budget' => $budget ]; $current_start_time = date('d/m/Y', strtotime($current_start_time . ' +' . $delta_time)); } var_dump($tasks_data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 79) Position 1 = -2
filename:       /in/dgjfN
function name:  (null)
number of ops:  124
compiled vars:  !0 = $facturation, !1 = $tasks_data, !2 = $current_start_time, !3 = $mtt_per_period, !4 = $delta_time, !5 = $i, !6 = $current_end_time, !7 = $budget
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          4        INIT_FCALL                                               'strtotime'
          5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '%2F'
          7        SEND_VAL                                                 '-'
          8        FETCH_DIM_R                                      ~9      !0, 'start_time'
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11        SEND_VAR                                                 $10
         12        DO_ICALL                                         $11     
         13        SEND_VAR                                                 $11
         14        DO_ICALL                                         $12     
         15        SEND_VAR                                                 $12
         16        DO_ICALL                                                 
   10    17      > EXIT                                                     
   13    18*       ASSIGN                                                   !1, <array>
   14    19*       INIT_FCALL                                               'date'
         20*       SEND_VAL                                                 'Y-m-d'
         21*       INIT_FCALL                                               'strtotime'
         22*       INIT_FCALL                                               'str_replace'
         23*       SEND_VAL                                                 '%2F'
         24*       SEND_VAL                                                 '-'
         25*       FETCH_DIM_R                                      ~15     !0, 'start_time'
         26*       SEND_VAL                                                 ~15
         27*       DO_ICALL                                         $16     
         28*       SEND_VAR                                                 $16
         29*       DO_ICALL                                         $17     
         30*       SEND_VAR                                                 $17
         31*       DO_ICALL                                         $18     
         32*       ASSIGN                                                   !2, $18
   17    33*       FETCH_DIM_R                                      ~20     !0, 'mtt'
         34*       CAST                                          5  ~21     ~20
         35*       FETCH_DIM_R                                      ~22     !0, 'periodicite'
         36*       CAST                                          5  ~23     ~22
         37*       DIV                                              ~24     ~21, ~23
         38*       ASSIGN                                                   !3, ~24
   18    39*       INIT_FCALL                                               'number_format'
         40*       CAST                                          5  ~26     !3
         41*       SEND_VAL                                                 ~26
         42*       SEND_VAL                                                 2
         43*       SEND_VAL                                                 '.'
         44*       SEND_VAL                                                 ''
         45*       DO_ICALL                                         $27     
         46*       ASSIGN                                                   !3, $27
   19    47*       FETCH_DIM_R                                      ~29     !0, 'periodicite'
         48*       IS_EQUAL                                                 ~29, '12'
         49*       JMPZ                                                     ~30, ->52
         50*       QM_ASSIGN                                        ~31     '1+month'
         51*       JMP                                                      ->53
         52*       QM_ASSIGN                                        ~31     '1+year'
         53*       ASSIGN                                                   !4, ~31
   21    54*       ASSIGN                                                   !5, 0
         55*       JMP                                                      ->117
   22    56*       INIT_FCALL                                               'date'
         57*       SEND_VAL                                                 'd%2Fm%2FY'
         58*       INIT_FCALL                                               'strtotime'
         59*       CONCAT                                           ~34     !2, '+%2B'
         60*       CONCAT                                           ~35     ~34, !4
         61*       SEND_VAL                                                 ~35
         62*       DO_ICALL                                         $36     
         63*       SEND_VAR                                                 $36
         64*       DO_ICALL                                         $37     
         65*       ASSIGN                                                   !6, $37
   24    66*       ASSIGN                                                   !7, !3
   25    67*       FETCH_DIM_R                                      ~40     !0, 'periodicite'
         68*       CAST                                          4  ~41     ~40
         69*       SUB                                              ~42     ~41, 1
         70*       IS_IDENTICAL                                             !5, ~42
         71*       JMPZ                                                     ~43, ->88
   26    72*       FETCH_DIM_R                                      ~44     !0, 'mtt'
         73*       CAST                                          5  ~45     ~44
         74*       FETCH_DIM_R                                      ~46     !0, 'periodicite'
         75*       CAST                                          5  ~47     ~46
         76*       SUB                                              ~48     ~47, 1
         77*       MUL                                              ~49     !3, ~48
         78*       SUB                                              ~50     ~45, ~49
         79*       ASSIGN                                                   !7, ~50
   27    80*       INIT_FCALL                                               'number_format'
         81*       CAST                                          5  ~52     !7
         82*       SEND_VAL                                                 ~52
         83*       SEND_VAL                                                 2
         84*       SEND_VAL                                                 '.'
         85*       SEND_VAL                                                 ''
         86*       DO_ICALL                                         $53     
         87*       ASSIGN                                                   !7, $53
   31    88*       INIT_ARRAY                                       ~56     !2, 'start_time'
   32    89*       ADD_ARRAY_ELEMENT                                ~56     !6, 'end_time'
   33    90*       FETCH_DIM_R                                      ~57     !0, 'periodicite'
         91*       IS_EQUAL                                                 ~57, '12'
         92*       JMPZ                                                     ~58, ->101
         93*       INIT_FCALL                                               'explode'
         94*       SEND_VAL                                                 '%2F'
         95*       SEND_VAR                                                 !2
         96*       DO_ICALL                                         $59     
         97*       FETCH_DIM_R                                      ~60     $59, 2
         98*       CONCAT                                           ~61     'acompte+', ~60
         99*       QM_ASSIGN                                        ~62     ~61
        100*       JMP                                                      ->102
        101*       QM_ASSIGN                                        ~62     '%C3%A9ch%C3%A9ance+unique'
        102*       ADD_ARRAY_ELEMENT                                ~56     ~62, 'title'
   34   103*       ADD_ARRAY_ELEMENT                                ~56     !7, 'budget'
   30   104*       ASSIGN_DIM                                               !1
   34   105*       OP_DATA                                                  ~56
   37   106*       INIT_FCALL                                               'date'
        107*       SEND_VAL                                                 'd%2Fm%2FY'
        108*       INIT_FCALL                                               'strtotime'
        109*       CONCAT                                           ~63     !2, '+%2B'
        110*       CONCAT                                           ~64     ~63, !4
        111*       SEND_VAL                                                 ~64
        112*       DO_ICALL                                         $65     
        113*       SEND_VAR                                                 $65
        114*       DO_ICALL                                         $66     
        115*       ASSIGN                                                   !2, $66
   21   116*       PRE_INC                                                  !5
        117*       FETCH_DIM_R                                      ~69     !0, 'periodicite'
        118*       IS_SMALLER                                               !5, ~69
        119*       JMPNZ                                                    ~70, ->56
   40   120*       INIT_FCALL                                               'var_dump'
        121*       SEND_VAR                                                 !1
        122*       DO_ICALL                                                 
        123*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.53 ms | 1404 KiB | 25 Q