3v4l.org

run code in 300+ PHP versions simultaneously
<?php function &random_value(&$array, $default=null) { $k = 0; // mt_rand(0, count($array) - 1); if (isset($array[$k])) { return $array[$k]; } else { return $default; } } $companies = array(); $companies[] = array("name" => "Acme Co", "employees"=> array( "John", "Jane" )); $companies[] = array("name" => "Inotech", "employees"=> array( "Bill", "Michael" )); $x = &random_value($companies); $x["employees"][] = "Donald"; var_dump($x, $companies);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f7cn9
function name:  (null)
number of ops:  17
compiled vars:  !0 = $companies, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   14     1        ASSIGN_DIM                                               !0
          2        OP_DATA                                                  <array>
   15     3        ASSIGN_DIM                                               !0
          4        OP_DATA                                                  <array>
   17     5        INIT_FCALL                                               'random_value'
          6        SEND_REF                                                 !0
          7        DO_FCALL                                      0  $5      
          8        ASSIGN_REF                                               !1, $5
   18     9        FETCH_DIM_W                                      $7      !1, 'employees'
         10        ASSIGN_DIM                                               $7
         11        OP_DATA                                                  'Donald'
   19    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function random_value:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
Return found
Branch analysis from position: 8
Return found
filename:       /in/f7cn9
function name:  random_value
number of ops:  10
compiled vars:  !0 = $array, !1 = $default, !2 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      null
    5     2        ASSIGN                                                   !2, 0
    6     3        ISSET_ISEMPTY_DIM_OBJ                         0          !0, !2
          4      > JMPZ                                                     ~4, ->8
    7     5    >   FETCH_DIM_W                                      $5      !0, !2
          6      > RETURN_BY_REF                                            $5
          7*       JMP                                                      ->9
    9     8    > > RETURN_BY_REF                                            !1
   11     9*     > RETURN_BY_REF                                            null

End of function random_value

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.53 ms | 1403 KiB | 16 Q