3v4l.org

run code in 300+ PHP versions simultaneously
<?php $links = [ [ 'type_id' => '1', 'url' => '' ], [ 'type_id' => '2', 'url' => '' ] ]; $types = [ [ 'id' => 1, 'value' => 'facebook' ], [ 'id' => 2, 'value' => 'twitter' ] ]; $data = [ 'primary' => [ 'address_details' => [], 'contact_details' => [], 'social_links' => array_map(function ($v) use ($links) { return $links[array_search($v, array_column($links, 'type_id'))]; }, array_column($types, 'id', 'value')) ] ]; print_r($data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BHjoK
function name:  (null)
number of ops:  22
compiled vars:  !0 = $links, !1 = $types, !2 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   13     1        ASSIGN                                                   !1, <array>
   26     2        INIT_ARRAY                                       ~5      <array>, 'address_details'
          3        ADD_ARRAY_ELEMENT                                ~5      <array>, 'contact_details'
   28     4        INIT_FCALL                                               'array_map'
          5        DECLARE_LAMBDA_FUNCTION                          ~6      [0]
          6        BIND_LEXICAL                                             ~6, !0
          7        SEND_VAL                                                 ~6
          8        INIT_FCALL                                               'array_column'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'id'
         11        SEND_VAL                                                 'value'
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                         $8      
         15        ADD_ARRAY_ELEMENT                                ~5      $8, 'social_links'
         16        INIT_ARRAY                                       ~9      ~5, 'primary'
   24    17        ASSIGN                                                   !2, ~9
   31    18        INIT_FCALL                                               'print_r'
         19        SEND_VAR                                                 !2
         20        DO_ICALL                                                 
         21      > 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/BHjoK
function name:  {closure}
number of ops:  13
compiled vars:  !0 = $v, !1 = $links
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'array_search'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'array_column'
          5        SEND_VAR                                                 !1
          6        SEND_VAL                                                 'type_id'
          7        DO_ICALL                                         $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                         $3      
         10        FETCH_DIM_R                                      ~4      !1, $3
         11      > RETURN                                                   ~4
         12*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.1 ms | 1441 KiB | 17 Q