3v4l.org

run code in 500+ PHP versions simultaneously
<?php $s1 = '{ "b": "b", "2": "2", "3": "a", "4": "4", "6": "5", "7": "6" }'; $s2 = '{ "21": "b", "2": "2", "3": "3", "4": "4", "6": "5", "7": "6" }'; $e1 = json_decode($s1,true); $e2 = json_decode($s2,true); function custom_splice(&$ar, $a, $b){ $out = array_splice($ar, $a, 1); array_splice($ar, $b, 0, $out); } function moveElement(&$array, $a, $b) { $keys = array_keys($array); custom_splice($array, $a, $b); custom_splice($keys, $a, $b); $array = array_combine($keys,$array); } moveElement($e1, 2, 0); moveElement($e2, 2, 0); print_r($e1); print_r($e2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cntbB
function name:  (null)
number of ops:  29
compiled vars:  !0 = $s1, !1 = $s2, !2 = $e1, !3 = $e2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, '%7B+%22b%22%3A+%22b%22%2C+%222%22%3A+%222%22%2C+%223%22%3A+%22a%22%2C+%224%22%3A+%224%22%2C+%226%22%3A+%225%22%2C+%227%22%3A+%226%22+%7D'
    5     1        ASSIGN                                                       !1, '%7B+%2221%22%3A+%22b%22%2C+%222%22%3A+%222%22%2C+%223%22%3A+%223%22%2C+%224%22%3A+%224%22%2C+%226%22%3A+%225%22%2C+%227%22%3A+%226%22+%7D'
    7     2        INIT_FCALL                                                   'json_decode'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     <true>
          5        DO_ICALL                                             $6      
          6        ASSIGN                                                       !2, $6
    8     7        INIT_FCALL                                                   'json_decode'
          8        SEND_VAR                                                     !1
          9        SEND_VAL                                                     <true>
         10        DO_ICALL                                             $8      
         11        ASSIGN                                                       !3, $8
   24    12        INIT_FCALL                                                   'moveelement'
         13        SEND_REF                                                     !2
         14        SEND_VAL                                                     2
         15        SEND_VAL                                                     0
         16        DO_FCALL                                          0          
   25    17        INIT_FCALL                                                   'moveelement'
         18        SEND_REF                                                     !3
         19        SEND_VAL                                                     2
         20        SEND_VAL                                                     0
         21        DO_FCALL                                          0          
   27    22        INIT_FCALL                                                   'print_r'
         23        SEND_VAR                                                     !2
         24        DO_ICALL                                                     
   28    25        INIT_FCALL                                                   'print_r'
         26        SEND_VAR                                                     !3
         27        DO_ICALL                                                     
         28      > RETURN                                                       1

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

End of function custom_splice

Function moveelement:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/cntbB
function name:  moveElement
number of ops:  23
compiled vars:  !0 = $array, !1 = $a, !2 = $b, !3 = $keys
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   16     3        INIT_FCALL                                                   'array_keys'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $4      
          6        ASSIGN                                                       !3, $4
   18     7        INIT_FCALL                                                   'custom_splice'
          8        SEND_REF                                                     !0
          9        SEND_VAR                                                     !1
         10        SEND_VAR                                                     !2
         11        DO_FCALL                                          0          
   19    12        INIT_FCALL                                                   'custom_splice'
         13        SEND_REF                                                     !3
         14        SEND_VAR                                                     !1
         15        SEND_VAR                                                     !2
         16        DO_FCALL                                          0          
   21    17        INIT_FCALL                                                   'array_combine'
         18        SEND_VAR                                                     !3
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                             $8      
         21        ASSIGN                                                       !0, $8
   22    22      > RETURN                                                       null

End of function moveelement

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
161.53 ms | 2151 KiB | 22 Q