3v4l.org

run code in 300+ PHP versions simultaneously
<?php function d6() { return range(1,6); } $t = $i = 0; foreach(d6() as $a) { foreach(d6() as $b) { foreach(d6() as $c) { $t++; // includes both doubles and triples if($a==$b || $a == $c || $b == $c) { $i++; } } } } echo "$i doubles out of $t results.\n";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 29
Branch analysis from position: 6
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
2 jumps found. (Code = 47) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 47) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 24
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 24
Branch analysis from position: 22
Branch analysis from position: 19
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 27
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/bPa2X
function name:  (null)
number of ops:  36
compiled vars:  !0 = $t, !1 = $i, !2 = $a, !3 = $b, !4 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                           ~5      !1, 0
          1        ASSIGN                                                   !0, ~5
    6     2        INIT_FCALL                                               'd6'
          3        DO_FCALL                                      0  $7      
          4      > FE_RESET_R                                       $8      $7, ->29
          5    > > FE_FETCH_R                                               $8, !2, ->29
    7     6    >   INIT_FCALL                                               'd6'
          7        DO_FCALL                                      0  $9      
          8      > FE_RESET_R                                       $10     $9, ->27
          9    > > FE_FETCH_R                                               $10, !3, ->27
    8    10    >   INIT_FCALL                                               'd6'
         11        DO_FCALL                                      0  $11     
         12      > FE_RESET_R                                       $12     $11, ->25
         13    > > FE_FETCH_R                                               $12, !4, ->25
   10    14    >   PRE_INC                                                  !0
   12    15        IS_EQUAL                                         ~14     !2, !3
         16      > JMPNZ_EX                                         ~14     ~14, ->19
         17    >   IS_EQUAL                                         ~15     !2, !4
         18        BOOL                                             ~14     ~15
         19    > > JMPNZ_EX                                         ~14     ~14, ->22
         20    >   IS_EQUAL                                         ~16     !3, !4
         21        BOOL                                             ~14     ~16
         22    > > JMPZ                                                     ~14, ->24
   13    23    >   PRE_INC                                                  !1
    8    24    > > JMP                                                      ->13
         25    >   FE_FREE                                                  $12
    7    26      > JMP                                                      ->9
         27    >   FE_FREE                                                  $10
    6    28      > JMP                                                      ->5
         29    >   FE_FREE                                                  $8
   20    30        ROPE_INIT                                     4  ~19     !1
         31        ROPE_ADD                                      1  ~19     ~19, '+doubles+out+of+'
         32        ROPE_ADD                                      2  ~19     ~19, !0
         33        ROPE_END                                      3  ~18     ~19, '+results.%0A'
         34        ECHO                                                     ~18
         35      > RETURN                                                   1

Function d6:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bPa2X
function name:  d6
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'range'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 6
          3        DO_ICALL                                         $0      
          4      > RETURN                                                   $0
          5*     > RETURN                                                   null

End of function d6

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.36 ms | 1403 KiB | 18 Q