3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [1,2,3,4]; $rnd = array_rand($arr, 3); //What you are doing echo $arr[1] . " - " . $arr[2] . " - " . $arr[3]; echo "\n"; //What you want to do echo $arr[$rnd[0]] . " - " . $arr[$rnd[1]] . " - " . $arr[$rnd[2]];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aLl4i
function name:  (null)
number of ops:  27
compiled vars:  !0 = $arr, !1 = $rnd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'array_rand'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 3
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !1, $3
    7     6        FETCH_DIM_R                                      ~5      !0, 1
          7        CONCAT                                           ~6      ~5, '+-+'
          8        FETCH_DIM_R                                      ~7      !0, 2
          9        CONCAT                                           ~8      ~6, ~7
         10        CONCAT                                           ~9      ~8, '+-+'
         11        FETCH_DIM_R                                      ~10     !0, 3
         12        CONCAT                                           ~11     ~9, ~10
         13        ECHO                                                     ~11
    9    14        ECHO                                                     '%0A'
   12    15        FETCH_DIM_R                                      ~12     !1, 0
         16        FETCH_DIM_R                                      ~13     !0, ~12
         17        CONCAT                                           ~14     ~13, '+-+'
         18        FETCH_DIM_R                                      ~15     !1, 1
         19        FETCH_DIM_R                                      ~16     !0, ~15
         20        CONCAT                                           ~17     ~14, ~16
         21        CONCAT                                           ~18     ~17, '+-+'
         22        FETCH_DIM_R                                      ~19     !1, 2
         23        FETCH_DIM_R                                      ~20     !0, ~19
         24        CONCAT                                           ~21     ~18, ~20
         25        ECHO                                                     ~21
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.01 ms | 1010 KiB | 14 Q