3v4l.org

run code in 300+ PHP versions simultaneously
<?php $profiles = array( array( 'user_id' => 'fcc3d884-fbef-438a-9c86-0ad52c9b1223', 'first_name' => 'Narñia', 'middle_name' => 'Ñ', 'last_name' => 'Cruz', 'ext' => '' ), array( 'user_id' => '0d31557d-1e9f-4db3-ac0d-72e1709fe89c', 'first_name' => 'Randy', 'middle_name' => 'O', 'last_name' => 'Rocker', 'ext' => '' ), array( 'user_id' => '0f93f169-cf56-49df-a76b-7596446104c6', 'first_name' => 'Qwerty', 'middle_name' => 'K', 'last_name' => 'Asdfg', 'ext' => '' ), array( 'user_id' => '23b1f4a2-034c-43b4-96b7-3191d78cead1', 'first_name' => 'Johny', 'middle_name' => 'L', 'last_name' => 'Walker', 'ext' => '' ) ); $encoded = array( array( 'encoder_id' => '0d31557d-1e9f-4db3-ac0d-72e1709fe89c', 'fullname' => 'Randy O. Rocker', 'encoded' => 10, ), array( 'encoder_id' => '23b1f4a2-034c-43b4-96b7-3191d78cead1', 'fullname' => 'John L. Walker', 'encoded' => 20, ) ); $encoded_ids = array_column($encoded, null, 'encoder_id'); $data = array(); foreach ($profiles as $profile) { $user_id = $profile['user_id']; if (isset($encoded_ids[$user_id])) { $data[] = array('id' => $user_id, 'fullname' => $encoded_ids[$user_id]['fullname'], 'encoded' => $encoded_ids[$user_id]['encoded'] ); } else { $data[] = array('id' => $user_id, 'fullname' => "${profile['first_name']} ${profile['middle_name']} ${profile['last_name']}", 'encoded' => 0 ); } } usort($data, function ($a, $b) { return $b['encoded'] - $a['encoded'];}); print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 39
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 39
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 25
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
filename:       /in/FXtsE
function name:  (null)
number of ops:  49
compiled vars:  !0 = $profiles, !1 = $encoded, !2 = $encoded_ids, !3 = $data, !4 = $profile, !5 = $user_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   34     1        ASSIGN                                                   !1, <array>
   47     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'encoder_id'
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !2, $8
   49     8        ASSIGN                                                   !3, <array>
   50     9      > FE_RESET_R                                       $11     !0, ->39
         10    > > FE_FETCH_R                                               $11, !4, ->39
   51    11    >   FETCH_DIM_R                                      ~12     !4, 'user_id'
         12        ASSIGN                                                   !5, ~12
   52    13        ISSET_ISEMPTY_DIM_OBJ                         0          !2, !5
         14      > JMPZ                                                     ~14, ->25
   53    15    >   INIT_ARRAY                                       ~16     !5, 'id'
   54    16        FETCH_DIM_R                                      ~17     !2, !5
         17        FETCH_DIM_R                                      ~18     ~17, 'fullname'
         18        ADD_ARRAY_ELEMENT                                ~16     ~18, 'fullname'
   55    19        FETCH_DIM_R                                      ~19     !2, !5
         20        FETCH_DIM_R                                      ~20     ~19, 'encoded'
         21        ADD_ARRAY_ELEMENT                                ~16     ~20, 'encoded'
   53    22        ASSIGN_DIM                                               !3
   55    23        OP_DATA                                                  ~16
   52    24      > JMP                                                      ->38
   59    25    >   INIT_ARRAY                                       ~22     !5, 'id'
   60    26        FETCH_DIM_R                                      ~23     !4, 'first_name'
         27        ROPE_INIT                                     5  ~27     ~23
         28        ROPE_ADD                                      1  ~27     ~27, '+'
         29        FETCH_DIM_R                                      ~24     !4, 'middle_name'
         30        ROPE_ADD                                      2  ~27     ~27, ~24
         31        ROPE_ADD                                      3  ~27     ~27, '+'
         32        FETCH_DIM_R                                      ~25     !4, 'last_name'
         33        ROPE_END                                      4  ~26     ~27, ~25
         34        ADD_ARRAY_ELEMENT                                ~22     ~26, 'fullname'
   61    35        ADD_ARRAY_ELEMENT                                ~22     0, 'encoded'
   59    36        ASSIGN_DIM                                               !3
   61    37        OP_DATA                                                  ~22
   50    38    > > JMP                                                      ->10
         39    >   FE_FREE                                                  $11
   66    40        INIT_FCALL                                               'usort'
         41        SEND_REF                                                 !3
         42        DECLARE_LAMBDA_FUNCTION                          ~30     [0]
         43        SEND_VAL                                                 ~30
         44        DO_ICALL                                                 
   67    45        INIT_FCALL                                               'print_r'
         46        SEND_VAR                                                 !3
         47        DO_ICALL                                                 
         48      > 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/FXtsE
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        FETCH_DIM_R                                      ~2      !1, 'encoded'
          3        FETCH_DIM_R                                      ~3      !0, 'encoded'
          4        SUB                                              ~4      ~2, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.5 ms | 1452 KiB | 16 Q