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"], //["name" => "h", "gender" => "male"], //["name" => "i", "gender" => "male"], ]; $grouped = ['male' => [], 'female' => []]; foreach ($students as $student) { $grouped[$student["gender"]][] = $student; } var_export( array_merge( ...array_map( fn(...$g) => array_filter($g), $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/naU0E
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>
   15     1        ASSIGN                                                   !1, <array>
   16     2      > FE_RESET_R                                       $5      !0, ->9
          3    > > FE_FETCH_R                                               $5, !2, ->9
   17     4    >   FETCH_DIM_R                                      ~6      !2, 'gender'
          5        FETCH_DIM_W                                      $7      !1, ~6
          6        ASSIGN_DIM                                               $7
          7        OP_DATA                                                  !2
   16     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $5
   20    10        INIT_FCALL                                               'var_export'
   21    11        INIT_FCALL                                               'array_merge'
   22    12        INIT_FCALL                                               'array_map'
   23    13        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
         14        SEND_VAL                                                 ~9
   24    15        FETCH_DIM_R                                      ~10     !1, 'male'
         16        SEND_VAL                                                 ~10
   25    17        FETCH_DIM_R                                      ~11     !1, 'female'
         18        SEND_VAL                                                 ~11
   22    19        DO_ICALL                                         $12     
   25    20        SEND_UNPACK                                              $12
         21        CHECK_UNDEF_ARGS                                         
   21    22        DO_ICALL                                         $13     
   25    23        SEND_VAR                                                 $13
   20    24        DO_ICALL                                                 
   28    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/naU0E
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $g
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV_VARIADIC                                    !0      
          1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
          5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.86 ms | 1014 KiB | 17 Q