3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tests = ['1.2', '1.0', '2.11']; foreach ($tests as $yearWithDecimal) { $years = floor($yearWithDecimal); $months = ($yearWithDecimal - $years) * 12; $totalMonths = ($years * 12) + $months; echo $totalMonths.PHP_EOL; // Output is 14.4 }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 16
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 16
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/SbGA1
function name:  (null)
number of ops:  18
compiled vars:  !0 = $tests, !1 = $yearWithDecimal, !2 = $years, !3 = $months, !4 = $totalMonths
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $6      !0, ->16
          2    > > FE_FETCH_R                                               $6, !1, ->16
    8     3    >   INIT_FCALL                                               'floor'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !2, $7
    9     7        SUB                                              ~9      !1, !2
          8        MUL                                              ~10     ~9, 12
          9        ASSIGN                                                   !3, ~10
   11    10        MUL                                              ~12     !2, 12
         11        ADD                                              ~13     ~12, !3
         12        ASSIGN                                                   !4, ~13
   13    13        CONCAT                                           ~15     !4, '%0A'
         14        ECHO                                                     ~15
    5    15      > JMP                                                      ->2
         16    >   FE_FREE                                                  $6
   14    17      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.74 ms | 1004 KiB | 14 Q