3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(3,5,1,4,2,8,6,7,9,10); Echo findsum(6, $a); Function findsum($sum, $a){ Asort($a); $a = Array_values($a); Foreach($a as $key => $val){ If($val>=$sum) break; $find = $sum - $val; $subarr = array_slice($a, $key+1); If (in_array($find, $subarr)) echo $val . "+" . $find . "\n"; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FHViL
function name:  (null)
number of ops:  7
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL_BY_NAME                                       'findsum'
          2        SEND_VAL_EX                                              6
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0  $2      
          5        ECHO                                                     $2
   17     6      > RETURN                                                   1

Function findsum:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 33
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 33
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 32
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 32
Branch analysis from position: 33
Branch analysis from position: 33
filename:       /in/FHViL
function name:  findsum
number of ops:  35
compiled vars:  !0 = $sum, !1 = $a, !2 = $val, !3 = $key, !4 = $find, !5 = $subarr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        INIT_FCALL                                               'asort'
          3        SEND_REF                                                 !1
          4        DO_ICALL                                                 
   10     5        INIT_FCALL                                               'array_values'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
   11     9      > FE_RESET_R                                       $9      !1, ->33
         10    > > FE_FETCH_R                                       ~10     $9, !2, ->33
         11    >   ASSIGN                                                   !3, ~10
   12    12        IS_SMALLER_OR_EQUAL                                      !0, !2
         13      > JMPZ                                                     ~12, ->15
         14    > > JMP                                                      ->33
   13    15    >   SUB                                              ~13     !0, !2
         16        ASSIGN                                                   !4, ~13
   14    17        INIT_FCALL                                               'array_slice'
         18        SEND_VAR                                                 !1
         19        ADD                                              ~15     !3, 1
         20        SEND_VAL                                                 ~15
         21        DO_ICALL                                         $16     
         22        ASSIGN                                                   !5, $16
   15    23        INIT_FCALL                                               'in_array'
         24        SEND_VAR                                                 !4
         25        SEND_VAR                                                 !5
         26        DO_ICALL                                         $18     
         27      > JMPZ                                                     $18, ->32
         28    >   CONCAT                                           ~19     !2, '%2B'
         29        CONCAT                                           ~20     ~19, !4
         30        CONCAT                                           ~21     ~20, '%0A'
         31        ECHO                                                     ~21
   11    32    > > JMP                                                      ->10
         33    >   FE_FREE                                                  $9
   17    34      > RETURN                                                   null

End of function findsum

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
134.67 ms | 1405 KiB | 21 Q