3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = "/key/value/anotherKey/anotherValue/thirdKey/thirdValue"; $arr = explode("/", trim($string, "/")); $keys = array_flip(array_filter(array_flip($arr), function($k){ return ($k % 2 == 0); })); $values = array_flip(array_filter(array_flip($arr), function($k){ return ($k % 2 == 1); })); $result = array_combine($keys, $values); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AA3F8
function name:  (null)
number of ops:  40
compiled vars:  !0 = $string, !1 = $arr, !2 = $keys, !3 = $values, !4 = $result
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, '%2Fkey%2Fvalue%2FanotherKey%2FanotherValue%2FthirdKey%2FthirdValue'
    3     1        INIT_FCALL                                                   'explode'
          2        SEND_VAL                                                     '%2F'
          3        FRAMELESS_ICALL_2                trim                ~6      !0, '%2F'
          4        SEND_VAL                                                     ~6
          5        DO_ICALL                                             $7      
          6        ASSIGN                                                       !1, $7
    5     7        INIT_FCALL                                                   'array_flip'
          8        INIT_FCALL                                                   'array_filter'
          9        INIT_FCALL                                                   'array_flip'
         10        SEND_VAR                                                     !1
         11        DO_ICALL                                             $9      
         12        SEND_VAR                                                     $9
         13        DECLARE_LAMBDA_FUNCTION                              ~10     [0]
    7    14        SEND_VAL                                                     ~10
    5    15        DO_ICALL                                             $11     
    7    16        SEND_VAR                                                     $11
    5    17        DO_ICALL                                             $12     
         18        ASSIGN                                                       !2, $12
    9    19        INIT_FCALL                                                   'array_flip'
         20        INIT_FCALL                                                   'array_filter'
         21        INIT_FCALL                                                   'array_flip'
         22        SEND_VAR                                                     !1
         23        DO_ICALL                                             $14     
         24        SEND_VAR                                                     $14
         25        DECLARE_LAMBDA_FUNCTION                              ~15     [1]
   11    26        SEND_VAL                                                     ~15
    9    27        DO_ICALL                                             $16     
   11    28        SEND_VAR                                                     $16
    9    29        DO_ICALL                                             $17     
         30        ASSIGN                                                       !3, $17
   13    31        INIT_FCALL                                                   'array_combine'
         32        SEND_VAR                                                     !2
         33        SEND_VAR                                                     !3
         34        DO_ICALL                                             $19     
         35        ASSIGN                                                       !4, $19
   14    36        INIT_FCALL                                                   'print_r'
         37        SEND_VAR                                                     !4
         38        DO_ICALL                                                     
         39      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AA3F8
function name:  {closure:/in/AA3F8:5}
number of ops:  5
compiled vars:  !0 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    6     1        MOD                                                  ~1      !0, 2
          2        IS_EQUAL                                             ~2      ~1, 0
          3      > RETURN                                                       ~2
    7     4*     > RETURN                                                       null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AA3F8
function name:  {closure:/in/AA3F8:9}
number of ops:  5
compiled vars:  !0 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   RECV                                                 !0      
   10     1        MOD                                                  ~1      !0, 2
          2        IS_EQUAL                                             ~2      ~1, 1
          3      > RETURN                                                       ~2
   11     4*     > RETURN                                                       null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
158.7 ms | 2825 KiB | 18 Q