3v4l.org

run code in 500+ 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:  30
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        FRAMELESS_ICALL_2                trim                ~6      !0, '%2F'
          4        SEND_VAL                                                     ~6
          5        DO_ICALL                                             $7      
          6        ASSIGN                                                       !1, $7
    6     7        INIT_FCALL                                                   'array_filter'
          8        SEND_VAR                                                     !1
          9        DECLARE_LAMBDA_FUNCTION                              ~9      [0]
    8    10        SEND_VAL                                                     ~9
         11        SEND_VAL                                                     2
    6    12        DO_ICALL                                             $10     
         13        ASSIGN                                                       !2, $10
    9    14        INIT_FCALL                                                   'array_filter'
         15        SEND_VAR                                                     !1
         16        DECLARE_LAMBDA_FUNCTION                              ~12     [1]
   11    17        SEND_VAL                                                     ~12
         18        SEND_VAL                                                     2
    9    19        DO_ICALL                                             $13     
         20        ASSIGN                                                       !3, $13
   13    21        INIT_FCALL                                                   'array_combine'
         22        SEND_VAR                                                     !2
         23        SEND_VAR                                                     !3
         24        DO_ICALL                                             $15     
         25        ASSIGN                                                       !4, $15
   14    26        INIT_FCALL                                                   'print_r'
         27        SEND_VAR                                                     !4
         28        DO_ICALL                                                     
   16    29      > 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:/in/P0Ks4:6}
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:/in/P0Ks4: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:
160.85 ms | 2752 KiB | 17 Q