3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array(1,1,2,1,4,5,7,2,3); asort($array); $total = array_sum($array); $array1 = array(); $array2 = array(); $array3 = array(); foreach($array as $number) { if(array_sum($array1) < $total / 3) { array_push($array1, $number); } elseif(array_sum($array2) < $total / 3) { array_push($array2, $number); } else { array_push($array3, $number); } } echo array_sum($array3); foreach($array1 as $number) { if(array_sum($array3) + $number == $total / 3) { array_push($array3, $number); } else { echo 'no'; } } print_r($array1); print_r($array2); print_r($array3);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 40
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 40
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 35
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 40
2 jumps found. (Code = 77) Position 1 = 46, Position 2 = 61
Branch analysis from position: 46
2 jumps found. (Code = 78) Position 1 = 47, Position 2 = 61
Branch analysis from position: 47
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 59
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 61
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 61
Branch analysis from position: 40
filename:       /in/IOc2L
function name:  (null)
number of ops:  72
compiled vars:  !0 = $array, !1 = $total, !2 = $array1, !3 = $array2, !4 = $array3, !5 = $number
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'asort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    7     4        INIT_FCALL                                               'array_sum'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
    9     8        ASSIGN                                                   !2, <array>
   10     9        ASSIGN                                                   !3, <array>
   11    10        ASSIGN                                                   !4, <array>
   13    11      > FE_RESET_R                                       $13     !0, ->40
         12    > > FE_FETCH_R                                               $13, !5, ->40
   14    13    >   INIT_FCALL                                               'array_sum'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $14     
         16        DIV                                              ~15     !1, 3
         17        IS_SMALLER                                               $14, ~15
         18      > JMPZ                                                     ~16, ->24
   15    19    >   INIT_FCALL                                               'array_push'
         20        SEND_REF                                                 !2
         21        SEND_VAR                                                 !5
         22        DO_ICALL                                                 
         23      > JMP                                                      ->39
   16    24    >   INIT_FCALL                                               'array_sum'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                         $18     
         27        DIV                                              ~19     !1, 3
         28        IS_SMALLER                                               $18, ~19
         29      > JMPZ                                                     ~20, ->35
   17    30    >   INIT_FCALL                                               'array_push'
         31        SEND_REF                                                 !3
         32        SEND_VAR                                                 !5
         33        DO_ICALL                                                 
         34      > JMP                                                      ->39
   19    35    >   INIT_FCALL                                               'array_push'
         36        SEND_REF                                                 !4
         37        SEND_VAR                                                 !5
         38        DO_ICALL                                                 
   13    39    > > JMP                                                      ->12
         40    >   FE_FREE                                                  $13
   23    41        INIT_FCALL                                               'array_sum'
         42        SEND_VAR                                                 !4
         43        DO_ICALL                                         $23     
         44        ECHO                                                     $23
   24    45      > FE_RESET_R                                       $24     !2, ->61
         46    > > FE_FETCH_R                                               $24, !5, ->61
   25    47    >   INIT_FCALL                                               'array_sum'
         48        SEND_VAR                                                 !4
         49        DO_ICALL                                         $25     
         50        ADD                                              ~26     $25, !5
         51        DIV                                              ~27     !1, 3
         52        IS_EQUAL                                                 ~26, ~27
         53      > JMPZ                                                     ~28, ->59
   26    54    >   INIT_FCALL                                               'array_push'
         55        SEND_REF                                                 !4
         56        SEND_VAR                                                 !5
         57        DO_ICALL                                                 
         58      > JMP                                                      ->60
   28    59    >   ECHO                                                     'no'
   24    60    > > JMP                                                      ->46
         61    >   FE_FREE                                                  $24
   32    62        INIT_FCALL                                               'print_r'
         63        SEND_VAR                                                 !2
         64        DO_ICALL                                                 
   33    65        INIT_FCALL                                               'print_r'
         66        SEND_VAR                                                 !3
         67        DO_ICALL                                                 
   34    68        INIT_FCALL                                               'print_r'
         69        SEND_VAR                                                 !4
         70        DO_ICALL                                                 
         71      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.74 ms | 1400 KiB | 21 Q