3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array('fruit', 'apple', 'vegetable', 'corn'); $i = $j = 0; $newArr = array_combine( array_filter($arr, function()use(&$i){ return ++$i%2; }), array_filter($arr, function()use(&$j){ return $j++%2; }) ); unset($i, $j, $arr); print_r($newArr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZFpl
function name:  (null)
number of ops:  27
compiled vars:  !0 = $arr, !1 = $i, !2 = $j, !3 = $newArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                           ~5      !2, 0
          2        ASSIGN                                                   !1, ~5
    6     3        INIT_FCALL                                               'array_combine'
    7     4        INIT_FCALL                                               'array_filter'
          5        SEND_VAR                                                 !0
          6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaZFpl%3A7%240'
          7        BIND_LEXICAL                                             ~7, !1
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $8      
         10        SEND_VAR                                                 $8
    8    11        INIT_FCALL                                               'array_filter'
         12        SEND_VAR                                                 !0
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaZFpl%3A8%241'
         14        BIND_LEXICAL                                             ~9, !2
         15        SEND_VAL                                                 ~9
         16        DO_ICALL                                         $10     
         17        SEND_VAR                                                 $10
         18        DO_ICALL                                         $11     
    6    19        ASSIGN                                                   !3, $11
   10    20        UNSET_CV                                                 !1
         21        UNSET_CV                                                 !2
         22        UNSET_CV                                                 !0
   12    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaZFpl%3A7%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZFpl
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   BIND_STATIC                                              !0
          1        PRE_INC                                          ~1      !0
          2        MOD                                              ~2      ~1, 2
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaZFpl%3A7%240

Function %00%7Bclosure%7D%2Fin%2FaZFpl%3A8%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aZFpl
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   BIND_STATIC                                              !0
          1        POST_INC                                         ~1      !0
          2        MOD                                              ~2      ~1, 2
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaZFpl%3A8%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.26 ms | 1400 KiB | 19 Q