3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ ["person_id" => 22180, "position" => ["Secretary"], "person_name" => "Person 1"], ["person_id" => 51135, "position" => ["President"], "person_name" => "Person 2"], ["person_id" => 51136, "position" => ["General Secretary", "Committee Member"], "person_name" => "Person 3"], ["person_id" => 44141, "position" => ["Treasurer"], "person_name" => "Person 4"], ["person_id" => 51137, "position" => ["Committee Member"], "person_name" => "Person 5"] ]; $priorities = array_flip([ 'General Secretary', 'President', 'Treasurer', 'Secretary', 'Committee Member', ]); array_multisort( array_map( fn($row) => min( array_map( fn($p) => $priorities[$p], $row['position'] ) ), $array ), $array ); var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iaS7F
function name:  (null)
number of ops:  20
compiled vars:  !0 = $array, !1 = $priorities, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'array_flip'
   12     2        SEND_VAL                                                 <array>
   11     3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
   19     5        INIT_FCALL                                               'array_multisort'
   20     6        INIT_FCALL                                               'array_map'
   21     7        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          8        BIND_LEXICAL                                             ~6, !1
          9        BIND_LEXICAL                                             ~6, !2
   26    10        SEND_VAL                                                 ~6
   27    11        SEND_VAR                                                 !0
   20    12        DO_ICALL                                         $7      
   27    13        SEND_VAL                                                 $7
   29    14        SEND_REF                                                 !0
   19    15        DO_ICALL                                                 
   31    16        INIT_FCALL                                               'var_export'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
         19      > 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/iaS7F
function name:  {closure}
number of ops:  15
compiled vars:  !0 = $row, !1 = $priorities, !2 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        BIND_STATIC                                              !2
          3        INIT_FCALL                                               'min'
   22     4        INIT_FCALL                                               'array_map'
   23     5        DECLARE_LAMBDA_FUNCTION                          ~3      [0]
          6        BIND_LEXICAL                                             ~3, !1
          7        SEND_VAL                                                 ~3
   24     8        FETCH_DIM_R                                      ~4      !0, 'position'
          9        SEND_VAL                                                 ~4
   22    10        DO_ICALL                                         $5      
   24    11        SEND_VAR                                                 $5
   21    12        DO_ICALL                                         $6      
   24    13      > RETURN                                                   $6
   26    14*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iaS7F
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $p, !1 = $priorities
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !1, !0
          3      > RETURN                                                   ~2
          4*     > RETURN                                                   null

End of Dynamic Function 0

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.81 ms | 1019 KiB | 18 Q