3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'foo', 'bar', 'baz' ); srand(1); if (defined('MT_RAND_PHP')) mt_srand(1, MT_RAND_PHP); else mt_srand(1); function custom_array_rand() { global $array; $key = array_rand($array); var_dump('found key ' . $key); return $array[$key]; } var_dump( custom_array_rand(), custom_array_rand(), custom_array_rand() );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0gEEY
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        INIT_FCALL                                               'srand'
          2        SEND_VAL                                                 1
          3        DO_ICALL                                                 
   10     4        DEFINED                                                  'MT_RAND_PHP'
          5      > JMPZ                                                     ~3, ->12
   11     6    >   INIT_FCALL                                               'mt_srand'
          7        SEND_VAL                                                 1
          8        FETCH_CONSTANT                                   ~4      'MT_RAND_PHP'
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   10    11      > JMP                                                      ->15
   13    12    >   INIT_FCALL                                               'mt_srand'
         13        SEND_VAL                                                 1
         14        DO_ICALL                                                 
   21    15    >   INIT_FCALL                                               'var_dump'
   22    16        INIT_FCALL                                               'custom_array_rand'
         17        DO_FCALL                                      0  $7      
         18        SEND_VAR                                                 $7
   23    19        INIT_FCALL                                               'custom_array_rand'
         20        DO_FCALL                                      0  $8      
         21        SEND_VAR                                                 $8
   24    22        INIT_FCALL                                               'custom_array_rand'
         23        DO_FCALL                                      0  $9      
         24        SEND_VAR                                                 $9
   21    25        DO_ICALL                                                 
   25    26      > RETURN                                                   1

Function custom_array_rand:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0gEEY
function name:  custom_array_rand
number of ops:  12
compiled vars:  !0 = $array, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   BIND_GLOBAL                                              !0, 'array'
   16     1        INIT_FCALL                                               'array_rand'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
   17     5        INIT_FCALL                                               'var_dump'
          6        CONCAT                                           ~4      'found+key+', !1
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                                 
   18     9        FETCH_DIM_R                                      ~6      !0, !1
         10      > RETURN                                                   ~6
   19    11*     > RETURN                                                   null

End of function custom_array_rand

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.37 ms | 1021 KiB | 20 Q