3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "/key/value/anotherKey/anotherValue/thirdKey/thirdValue"; $arr = explode("/", trim($string, "/")); $keys = array_filter($arr, function($k){ return ($k % 2 == 0); }, ARRAY_FILTER_USE_KEY); $values = array_filter($arr, function($k){ return ($k % 2 == 1); }, ARRAY_FILTER_USE_KEY); $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/P0Ks4
function name:  (null)
number of ops:  33
compiled vars:  !0 = $string, !1 = $arr, !2 = $keys, !3 = $values, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2Fkey%2Fvalue%2FanotherKey%2FanotherValue%2FthirdKey%2FthirdValue'
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%2F'
          3        INIT_FCALL                                               'trim'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 '%2F'
          6        DO_ICALL                                         $6      
          7        SEND_VAR                                                 $6
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !1, $7
    6    10        INIT_FCALL                                               'array_filter'
         11        SEND_VAR                                                 !1
         12        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
    8    13        SEND_VAL                                                 ~9
         14        SEND_VAL                                                 2
    6    15        DO_ICALL                                         $10     
         16        ASSIGN                                                   !2, $10
    9    17        INIT_FCALL                                               'array_filter'
         18        SEND_VAR                                                 !1
         19        DECLARE_LAMBDA_FUNCTION                          ~12     [1]
   11    20        SEND_VAL                                                 ~12
         21        SEND_VAL                                                 2
    9    22        DO_ICALL                                         $13     
         23        ASSIGN                                                   !3, $13
   13    24        INIT_FCALL                                               'array_combine'
         25        SEND_VAR                                                 !2
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $15     
         28        ASSIGN                                                   !4, $15
   14    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
   16    32      > 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/P0Ks4
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        MOD                                              ~1      !0, 2
          2        IS_EQUAL                                         ~2      ~1, 0
          3      > RETURN                                                   ~2
    8     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/P0Ks4
function name:  {closure}
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.0.0


preferences:
149.04 ms | 1084 KiB | 18 Q