3v4l.org

run code in 300+ PHP versions simultaneously
<?php $profiles = [ [ 'user_id' => 'fcc3d884-fbef-438a-9c86-0ad52c9b1223', 'first_name' => 'Narñia', 'middle_name' => 'Ñ', 'last_name' => 'Cruz', 'ext' => '' ], [ 'user_id' => '0d31557d-1e9f-4db3-ac0d-72e1709fe89c', 'first_name' => 'Randy', 'middle_name' => 'O', 'last_name' => 'Rocker', 'ext' => '' ], [ 'user_id' => '0f93f169-cf56-49df-a76b-7596446104c6', 'first_name' => 'Qwerty', 'middle_name' => 'K', 'last_name' => 'Asdfg', 'ext' => '' ], [ 'user_id' => '23b1f4a2-034c-43b4-96b7-3191d78cead1', 'first_name' => 'Johny', 'middle_name' => 'L', 'last_name' => 'Walker', 'ext' => '' ] ]; $encoded = [ [ 'encoder_id' => '0d31557d-1e9f-4db3-ac0d-72e1709fe89c', 'fullname' => 'Randy O. Rocker', 'encoded' => 10, ], [ 'encoder_id' => '23b1f4a2-034c-43b4-96b7-3191d78cead1', 'fullname' => 'John L. Walker', 'encoded' => 20, ] ]; $encodedByEncoderId = array_column($encoded, null, 'encoder_id'); $combined = array_reduce($profiles, static function (array $combined, array $profile) use ($encodedByEncoderId) : array { $combined[] = [ 'id' => $profile['user_id'], 'fullname' => "{$profile['first_name']} {$profile['middle_name']}. {$profile['last_name']}", 'encoded' => $encodedByEncoderId[$profile['user_id']]['encoded'] ?? 0 ]; return $combined; }, []); print_r($combined);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kKBru
function name:  (null)
number of ops:  20
compiled vars:  !0 = $profiles, !1 = $encoded, !2 = $encodedByEncoderId, !3 = $combined
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                                         $6      
          7        ASSIGN                                                   !2, $6
   48     8        INIT_FCALL                                               'array_reduce'
          9        SEND_VAR                                                 !0
         10        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
         11        BIND_LEXICAL                                             ~8, !2
   55    12        SEND_VAL                                                 ~8
         13        SEND_VAL                                                 <array>
   48    14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !3, $9
   57    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !3
         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/kKBru
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $combined, !1 = $profile, !2 = $encodedByEncoderId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   48     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   50     3        FETCH_DIM_R                                      ~4      !1, 'user_id'
          4        INIT_ARRAY                                       ~5      ~4, 'id'
   51     5        FETCH_DIM_R                                      ~6      !1, 'first_name'
          6        ROPE_INIT                                     5  ~10     ~6
          7        ROPE_ADD                                      1  ~10     ~10, '+'
          8        FETCH_DIM_R                                      ~7      !1, 'middle_name'
          9        ROPE_ADD                                      2  ~10     ~10, ~7
         10        ROPE_ADD                                      3  ~10     ~10, '.+'
         11        FETCH_DIM_R                                      ~8      !1, 'last_name'
         12        ROPE_END                                      4  ~9      ~10, ~8
         13        ADD_ARRAY_ELEMENT                                ~5      ~9, 'fullname'
   52    14        FETCH_DIM_R                                      ~13     !1, 'user_id'
         15        FETCH_DIM_IS                                     ~14     !2, ~13
         16        FETCH_DIM_IS                                     ~15     ~14, 'encoded'
         17        COALESCE                                         ~16     ~15
         18        QM_ASSIGN                                        ~16     0
         19        ADD_ARRAY_ELEMENT                                ~5      ~16, 'encoded'
   49    20        ASSIGN_DIM                                               !0
   52    21        OP_DATA                                                  ~5
   54    22        VERIFY_RETURN_TYPE                                       !0
         23      > RETURN                                                   !0
   55    24*       VERIFY_RETURN_TYPE                                       
         25*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.69 ms | 1452 KiB | 16 Q