3v4l.org

run code in 500+ PHP versions simultaneously
<?php // $countAfter[$i][$j] will contain the number of occurrences of a pair $i, $j in the randomly generated sequence $countAfter = [1 => [1 => 0, 2 => 0], 2 => [1 => 0, 2 => 0] ]; $prev = 1; // We assume for simplicify that the "previously" generated value was 1 for ($i = 0; $i < 10000; $i++) { $n = mt_rand(1, 2); $countAfter[$prev][$n]++; $prev = $n; } print_r($countAfter);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 4
Branch analysis from position: 16
Branch analysis from position: 4
filename:       /in/sauQ9
function name:  (null)
number of ops:  20
compiled vars:  !0 = $countAfter, !1 = $prev, !2 = $i, !3 = $n
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    6     1        ASSIGN                                                       !1, 1
    7     2        ASSIGN                                                       !2, 0
          3      > JMP                                                          ->14
    8     4    >   INIT_FCALL                                                   'mt_rand'
          5        SEND_VAL                                                     1
          6        SEND_VAL                                                     2
          7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !3, $7
    9     9        FETCH_DIM_RW                                         $9      !0, !1
         10        FETCH_DIM_RW                                         $10     $9, !3
         11        PRE_INC                                                      $10
   10    12        ASSIGN                                                       !1, !3
    7    13        PRE_INC                                                      !2
         14    >   IS_SMALLER                                                   !2, 10000
         15      > JMPNZ                                                        ~14, ->4
   12    16    >   INIT_FCALL                                                   'print_r'
         17        SEND_VAR                                                     !0
         18        DO_ICALL                                                     
         19      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
151.04 ms | 558 KiB | 10 Q