3v4l.org

run code in 300+ PHP versions simultaneously
<?php $numbs = [1,2,50.2,5.43,1.22,1.9,10.999,-20.5,-15.8,-2.75]; foreach($numbs as $num) { $mod = $num < 0 ? -1 : 1; $absNum = abs($num); if($absNum >= ((int) $absNum) + 0.75) { // Round Up $roundedNum = ceil($absNum) * $mod; } else { //Round Down $roundedNum = floor($absNum) * $mod; } echo $num . ' Rounded to ' . $roundedNum . "\n"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 33
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 33
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 23
Branch analysis from position: 17
Branch analysis from position: 23
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
filename:       /in/1nhLV
function name:  (null)
number of ops:  35
compiled vars:  !0 = $numbs, !1 = $num, !2 = $mod, !3 = $absNum, !4 = $roundedNum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1      > FE_RESET_R                                       $6      !0, ->33
          2    > > FE_FETCH_R                                               $6, !1, ->33
    6     3    >   IS_SMALLER                                               !1, 0
          4      > JMPZ                                                     ~7, ->7
          5    >   QM_ASSIGN                                        ~8      -1
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~8      1
          8    >   ASSIGN                                                   !2, ~8
    7     9        INIT_FCALL                                               'abs'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !3, $10
    8    13        CAST                                          4  ~12     !3
         14        ADD                                              ~13     ~12, 0.75
         15        IS_SMALLER_OR_EQUAL                                      ~13, !3
         16      > JMPZ                                                     ~14, ->23
   10    17    >   INIT_FCALL                                               'ceil'
         18        SEND_VAR                                                 !3
         19        DO_ICALL                                         $15     
         20        MUL                                              ~16     !2, $15
         21        ASSIGN                                                   !4, ~16
         22      > JMP                                                      ->28
   13    23    >   INIT_FCALL                                               'floor'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $18     
         26        MUL                                              ~19     !2, $18
         27        ASSIGN                                                   !4, ~19
   15    28    >   CONCAT                                           ~21     !1, '+Rounded+to+'
         29        CONCAT                                           ~22     ~21, !4
         30        CONCAT                                           ~23     ~22, '%0A'
         31        ECHO                                                     ~23
    5    32      > JMP                                                      ->2
         33    >   FE_FREE                                                  $6
   16    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.48 ms | 1405 KiB | 19 Q