3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'one', 'two', 'three', 'four' ]; $n = 10; $result = []; for ($x = 0; $x < $n; $x += (int) (!$x || $result[$x] !== $result[$x - 1])) { $result[$x] = $array[array_rand($array)]; } echo json_encode($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 47) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 22, Position 2 = 5
Branch analysis from position: 22
Branch analysis from position: 5
Branch analysis from position: 18
filename:       /in/ZuoI3
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $n, !2 = $result, !3 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, 10
   11     2        ASSIGN                                                   !2, <array>
   12     3        ASSIGN                                                   !3, 0
          4      > JMP                                                      ->20
   13     5    >   INIT_FCALL                                               'array_rand'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $9      
          8        FETCH_DIM_R                                      ~10     !0, $9
          9        ASSIGN_DIM                                               !2, !3
         10        OP_DATA                                                  ~10
   12    11        BOOL_NOT                                         ~11     !3
         12      > JMPNZ_EX                                         ~11     ~11, ->18
         13    >   FETCH_DIM_R                                      ~12     !2, !3
         14        SUB                                              ~13     !3, 1
         15        FETCH_DIM_R                                      ~14     !2, ~13
         16        IS_NOT_IDENTICAL                                 ~15     ~12, ~14
         17        BOOL                                             ~11     ~15
         18    >   CAST                                          4  ~16     ~11
         19        ASSIGN_OP                                     1          !3, ~16
         20    >   IS_SMALLER                                               !3, !1
         21      > JMPNZ                                                    ~18, ->5
   15    22    >   INIT_FCALL                                               'json_encode'
         23        SEND_VAR                                                 !2
         24        DO_ICALL                                         $19     
         25        ECHO                                                     $19
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.38 ms | 1012 KiB | 15 Q