3v4l.org

run code in 300+ PHP versions simultaneously
<?php $students = [ ["name" => "...", "gender" => "male"], ["name" => "...", "gender" => "female"], ["name" => "...", "gender" => "female"], ["name" => "...", "gender" => "female"], ["name" => "...", "gender" => "male"], ["name" => "...", "gender" => "female"], ["name" => "...", "gender" => "male"], ]; $males = array_filter($students, function ($e) { return $e["gender"] === "male"; }); $females = array_filter($students, function ($e) { return $e["gender"] === "female"; }); $zipped = array_map(null, $males, $females); $result = array_reduce($zipped, function ($a, $e) { if ($e[0]) $a[] = $e[0]; if ($e[1]) $a[] = $e[1]; return $a; }, []); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SSrUK
function name:  (null)
number of ops:  30
compiled vars:  !0 = $students, !1 = $males, !2 = $females, !3 = $zipped, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
   15     4        SEND_VAL                                                 ~6
   13     5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !1, $7
   16     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !0
          9        DECLARE_LAMBDA_FUNCTION                          ~9      [1]
   18    10        SEND_VAL                                                 ~9
   16    11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !2, $10
   19    13        INIT_FCALL                                               'array_map'
         14        SEND_VAL                                                 null
         15        SEND_VAR                                                 !1
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                         $12     
         18        ASSIGN                                                   !3, $12
   20    19        INIT_FCALL                                               'array_reduce'
         20        SEND_VAR                                                 !3
         21        DECLARE_LAMBDA_FUNCTION                          ~14     [2]
   24    22        SEND_VAL                                                 ~14
         23        SEND_VAL                                                 <array>
   20    24        DO_ICALL                                         $15     
         25        ASSIGN                                                   !4, $15
   25    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
         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/SSrUK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_DIM_R                                      ~1      !0, 'gender'
          2        IS_IDENTICAL                                     ~2      ~1, 'male'
          3      > RETURN                                                   ~2
   15     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/SSrUK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        FETCH_DIM_R                                      ~1      !0, 'gender'
          2        IS_IDENTICAL                                     ~2      ~1, 'female'
          3      > RETURN                                                   ~2
   18     4*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
Branch analysis from position: 7
filename:       /in/SSrUK
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $a, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   21     2        FETCH_DIM_R                                      ~2      !1, 0
          3      > JMPZ                                                     ~2, ->7
          4    >   FETCH_DIM_R                                      ~4      !1, 0
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~4
   22     7    >   FETCH_DIM_R                                      ~5      !1, 1
          8      > JMPZ                                                     ~5, ->12
          9    >   FETCH_DIM_R                                      ~7      !1, 1
         10        ASSIGN_DIM                                               !0
         11        OP_DATA                                                  ~7
   23    12    > > RETURN                                                   !0
   24    13*     > RETURN                                                   null

End of Dynamic Function 2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
277.92 ms | 1018 KiB | 17 Q