3v4l.org

run code in 300+ PHP versions simultaneously
<?php // you can use print for debugging purposes, e.g. // print "this is a debug message\n"; function solution($A) { $B = array_splice($A, 1); $length = count($B); $t1 = $A[0]; $t2 = array_sum($B); $i = 0; $diff = abs($t1 - $t2); echo "Diff:" . $diff; do { $newDiff = abs (($t1 + $B[$i]) - ($t2 + $B[$i])); var_dump($newDiff); if ($newDiff < $diff) { $diff = $newDif; $i++; $length --; } else { break; } } while ($length > 1); return $diff; } echo solution([3,1,2,4,3]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tvT9k
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'solution'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function solution:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 40
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 22
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
filename:       /in/tvT9k
function name:  solution
number of ops:  45
compiled vars:  !0 = $A, !1 = $B, !2 = $length, !3 = $t1, !4 = $t2, !5 = $i, !6 = $diff, !7 = $newDiff, !8 = $newDif
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'array_splice'
          2        SEND_REF                                                 !0
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
    8     6        COUNT                                            ~11     !1
          7        ASSIGN                                                   !2, ~11
    9     8        FETCH_DIM_R                                      ~13     !0, 0
          9        ASSIGN                                                   !3, ~13
   10    10        INIT_FCALL                                               'array_sum'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $15     
         13        ASSIGN                                                   !4, $15
   11    14        ASSIGN                                                   !5, 0
   12    15        INIT_FCALL                                               'abs'
         16        SUB                                              ~18     !3, !4
         17        SEND_VAL                                                 ~18
         18        DO_ICALL                                         $19     
         19        ASSIGN                                                   !6, $19
   13    20        CONCAT                                           ~21     'Diff%3A', !6
         21        ECHO                                                     ~21
   15    22    >   INIT_FCALL                                               'abs'
         23        FETCH_DIM_R                                      ~22     !1, !5
         24        ADD                                              ~23     !3, ~22
         25        FETCH_DIM_R                                      ~24     !1, !5
         26        ADD                                              ~25     !4, ~24
         27        SUB                                              ~26     ~23, ~25
         28        SEND_VAL                                                 ~26
         29        DO_ICALL                                         $27     
         30        ASSIGN                                                   !7, $27
   16    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !7
         33        DO_ICALL                                                 
   17    34        IS_SMALLER                                               !7, !6
         35      > JMPZ                                                     ~30, ->40
   18    36    >   ASSIGN                                                   !6, !8
   19    37        PRE_INC                                                  !5
   20    38        PRE_DEC                                                  !2
         39      > JMP                                                      ->41
   22    40    > > JMP                                                      ->43
   25    41    >   IS_SMALLER                                               1, !2
         42      > JMPNZ                                                    ~34, ->22
   27    43    > > RETURN                                                   !6
   28    44*     > RETURN                                                   null

End of function solution

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.57 ms | 1394 KiB | 22 Q