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); for ($index = 0, $length = count($keys); $index < $length; ++$index) { $result[$keys[$index]] = $arr[$keys[$index]]; } $arr = $result; } $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/C11n9
function name:  (null)
number of ops:  8
compiled vars:  !0 = $arr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL                                               'preserve_shuffle'
          2        SEND_REF                                                 !0
          3        DO_FCALL                                      0          
   15     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 = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 12
Branch analysis from position: 20
Branch analysis from position: 12
filename:       /in/C11n9
function name:  preserve_shuffle
number of ops:  22
compiled vars:  !0 = $arr, !1 = $keys, !2 = $index, !3 = $length, !4 = $result
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                                         $5      
          4        ASSIGN                                                   !1, $5
    6     5        INIT_FCALL                                               'shuffle'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                                 
    7     8        ASSIGN                                                   !2, 0
          9        COUNT                                            ~9      !1
         10        ASSIGN                                                   !3, ~9
         11      > JMP                                                      ->18
    8    12    >   FETCH_DIM_R                                      ~11     !1, !2
         13        FETCH_DIM_R                                      ~13     !1, !2
         14        FETCH_DIM_R                                      ~14     !0, ~13
         15        ASSIGN_DIM                                               !4, ~11
         16        OP_DATA                                                  ~14
    7    17        PRE_INC                                                  !2
         18    >   IS_SMALLER                                               !2, !3
         19      > JMPNZ                                                    ~16, ->12
   10    20    >   ASSIGN                                                   !0, !4
   11    21      > RETURN                                                   null

End of function preserve_shuffle

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
132.51 ms | 1403 KiB | 20 Q