3v4l.org

run code in 300+ PHP versions simultaneously
<?php function preserve_shuffle(&$arr) #Shuffles the key-value associations in an array. { $keys = array_keys($arr); #extract the keys from the array. shuffle($keys); $arr = array_merge(array_flip($keys), $arr); } $arr = ["a" => "apple", "b" => "banana", "c" => "capsicum", "d" => "dill"]; preserve_shuffle($arr); var_export($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eLMo6
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'preserve_shuffle'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   12     4        INIT_FCALL                                               'var_export'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function preserve_shuffle:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eLMo6
function name:  preserve_shuffle
number of ops:  17
compiled vars:  !0 = $arr, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
    6     5        INIT_FCALL                                               'shuffle'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                                 
    7     8        INIT_FCALL                                               'array_merge'
          9        INIT_FCALL                                               'array_flip'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $6      
         15        ASSIGN                                                   !0, $6
    8    16      > RETURN                                                   null

End of function preserve_shuffle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.37 ms | 1402 KiB | 24 Q