3v4l.org

run code in 300+ PHP versions simultaneously
<?php $facturation = [ 'start_time' => '27/06/2017', 'mtt' => '50000', 'periodicite' => '12' ]; var_dump(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/gYpGN
function name:  (null)
number of ops:  120
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                                               'strtotime'
          3        INIT_FCALL                                               'str_replace'
          4        SEND_VAL                                                 '%2F'
          5        SEND_VAL                                                 '-'
          6        FETCH_DIM_R                                      ~9      !0, 'start_time'
          7        SEND_VAL                                                 ~9
          8        DO_ICALL                                         $10     
          9        SEND_VAR                                                 $10
         10        DO_ICALL                                         $11     
         11        SEND_VAR                                                 $11
         12        DO_ICALL                                                 
   10    13      > EXIT                                                     
   13    14*       ASSIGN                                                   !1, <array>
   14    15*       INIT_FCALL                                               'date'
         16*       SEND_VAL                                                 'Y-m-d'
         17*       INIT_FCALL                                               'strtotime'
         18*       INIT_FCALL                                               'str_replace'
         19*       SEND_VAL                                                 '%2F'
         20*       SEND_VAL                                                 '-'
         21*       FETCH_DIM_R                                      ~14     !0, 'start_time'
         22*       SEND_VAL                                                 ~14
         23*       DO_ICALL                                         $15     
         24*       SEND_VAR                                                 $15
         25*       DO_ICALL                                         $16     
         26*       SEND_VAR                                                 $16
         27*       DO_ICALL                                         $17     
         28*       ASSIGN                                                   !2, $17
   17    29*       FETCH_DIM_R                                      ~19     !0, 'mtt'
         30*       CAST                                          5  ~20     ~19
         31*       FETCH_DIM_R                                      ~21     !0, 'periodicite'
         32*       CAST                                          5  ~22     ~21
         33*       DIV                                              ~23     ~20, ~22
         34*       ASSIGN                                                   !3, ~23
   18    35*       INIT_FCALL                                               'number_format'
         36*       CAST                                          5  ~25     !3
         37*       SEND_VAL                                                 ~25
         38*       SEND_VAL                                                 2
         39*       SEND_VAL                                                 '.'
         40*       SEND_VAL                                                 ''
         41*       DO_ICALL                                         $26     
         42*       ASSIGN                                                   !3, $26
   19    43*       FETCH_DIM_R                                      ~28     !0, 'periodicite'
         44*       IS_EQUAL                                                 ~28, '12'
         45*       JMPZ                                                     ~29, ->48
         46*       QM_ASSIGN                                        ~30     '1+month'
         47*       JMP                                                      ->49
         48*       QM_ASSIGN                                        ~30     '1+year'
         49*       ASSIGN                                                   !4, ~30
   21    50*       ASSIGN                                                   !5, 0
         51*       JMP                                                      ->113
   22    52*       INIT_FCALL                                               'date'
         53*       SEND_VAL                                                 'd%2Fm%2FY'
         54*       INIT_FCALL                                               'strtotime'
         55*       CONCAT                                           ~33     !2, '+%2B'
         56*       CONCAT                                           ~34     ~33, !4
         57*       SEND_VAL                                                 ~34
         58*       DO_ICALL                                         $35     
         59*       SEND_VAR                                                 $35
         60*       DO_ICALL                                         $36     
         61*       ASSIGN                                                   !6, $36
   24    62*       ASSIGN                                                   !7, !3
   25    63*       FETCH_DIM_R                                      ~39     !0, 'periodicite'
         64*       CAST                                          4  ~40     ~39
         65*       SUB                                              ~41     ~40, 1
         66*       IS_IDENTICAL                                             !5, ~41
         67*       JMPZ                                                     ~42, ->84
   26    68*       FETCH_DIM_R                                      ~43     !0, 'mtt'
         69*       CAST                                          5  ~44     ~43
         70*       FETCH_DIM_R                                      ~45     !0, 'periodicite'
         71*       CAST                                          5  ~46     ~45
         72*       SUB                                              ~47     ~46, 1
         73*       MUL                                              ~48     !3, ~47
         74*       SUB                                              ~49     ~44, ~48
         75*       ASSIGN                                                   !7, ~49
   27    76*       INIT_FCALL                                               'number_format'
         77*       CAST                                          5  ~51     !7
         78*       SEND_VAL                                                 ~51
         79*       SEND_VAL                                                 2
         80*       SEND_VAL                                                 '.'
         81*       SEND_VAL                                                 ''
         82*       DO_ICALL                                         $52     
         83*       ASSIGN                                                   !7, $52
   31    84*       INIT_ARRAY                                       ~55     !2, 'start_time'
   32    85*       ADD_ARRAY_ELEMENT                                ~55     !6, 'end_time'
   33    86*       FETCH_DIM_R                                      ~56     !0, 'periodicite'
         87*       IS_EQUAL                                                 ~56, '12'
         88*       JMPZ                                                     ~57, ->97
         89*       INIT_FCALL                                               'explode'
         90*       SEND_VAL                                                 '%2F'
         91*       SEND_VAR                                                 !2
         92*       DO_ICALL                                         $58     
         93*       FETCH_DIM_R                                      ~59     $58, 2
         94*       CONCAT                                           ~60     'acompte+', ~59
         95*       QM_ASSIGN                                        ~61     ~60
         96*       JMP                                                      ->98
         97*       QM_ASSIGN                                        ~61     '%C3%A9ch%C3%A9ance+unique'
         98*       ADD_ARRAY_ELEMENT                                ~55     ~61, 'title'
   34    99*       ADD_ARRAY_ELEMENT                                ~55     !7, 'budget'
   30   100*       ASSIGN_DIM                                               !1
   34   101*       OP_DATA                                                  ~55
   37   102*       INIT_FCALL                                               'date'
        103*       SEND_VAL                                                 'd%2Fm%2FY'
        104*       INIT_FCALL                                               'strtotime'
        105*       CONCAT                                           ~62     !2, '+%2B'
        106*       CONCAT                                           ~63     ~62, !4
        107*       SEND_VAL                                                 ~63
        108*       DO_ICALL                                         $64     
        109*       SEND_VAR                                                 $64
        110*       DO_ICALL                                         $65     
        111*       ASSIGN                                                   !2, $65
   21   112*       PRE_INC                                                  !5
        113*       FETCH_DIM_R                                      ~68     !0, 'periodicite'
        114*       IS_SMALLER                                               !5, ~68
        115*       JMPNZ                                                    ~69, ->52
   40   116*       INIT_FCALL                                               'var_dump'
        117*       SEND_VAR                                                 !1
        118*       DO_ICALL                                                 
        119*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.25 ms | 1409 KiB | 25 Q