3v4l.org

run code in 300+ PHP versions simultaneously
<?php $students = [ ["name" => "a", "gender" => "male"], ["name" => "b", "gender" => "female"], ["name" => "c", "gender" => "female"], ["name" => "d", "gender" => "female"], ["name" => "e", "gender" => "male"], ["name" => "f", "gender" => "male"], ["name" => "g", "gender" => "male"], ]; $grouped = ['male' => [], 'female' => []]; foreach ($students as $student) { $grouped[$student["gender"]][] = $student; } var_export( array_merge( ...array_map( fn($m, $f) => [$m ?? [], $f ?? []], $grouped['male'], $grouped['female'] ) ) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/ZRAGA
function name:  (null)
number of ops:  26
compiled vars:  !0 = $students, !1 = $grouped, !2 = $student
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   14     2      > FE_RESET_R                                       $5      !0, ->9
          3    > > FE_FETCH_R                                               $5, !2, ->9
   15     4    >   FETCH_DIM_R                                      ~6      !2, 'gender'
          5        FETCH_DIM_W                                      $7      !1, ~6
          6        ASSIGN_DIM                                               $7
          7        OP_DATA                                                  !2
   14     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $5
   18    10        INIT_FCALL                                               'var_export'
   19    11        INIT_FCALL                                               'array_merge'
   20    12        INIT_FCALL                                               'array_map'
   21    13        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
         14        SEND_VAL                                                 ~9
   22    15        FETCH_DIM_R                                      ~10     !1, 'male'
         16        SEND_VAL                                                 ~10
   23    17        FETCH_DIM_R                                      ~11     !1, 'female'
         18        SEND_VAL                                                 ~11
   20    19        DO_ICALL                                         $12     
   23    20        SEND_UNPACK                                              $12
         21        CHECK_UNDEF_ARGS                                         
   19    22        DO_ICALL                                         $13     
   23    23        SEND_VAR                                                 $13
   18    24        DO_ICALL                                                 
   26    25      > 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/ZRAGA
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $m, !1 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        COALESCE                                         ~2      !0
          3        QM_ASSIGN                                        ~2      <array>
          4        INIT_ARRAY                                       ~3      ~2
          5        COALESCE                                         ~4      !1
          6        QM_ASSIGN                                        ~4      <array>
          7        ADD_ARRAY_ELEMENT                                ~3      ~4
          8      > RETURN                                                   ~3
          9*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
124.25 ms | 1017 KiB | 16 Q