3v4l.org

run code in 300+ PHP versions simultaneously
<?php $books_sorted = array( 0 => array( "title" => "In Search of Lost Time", "count" => 2 ), 1 => array( "title" => "Don Quixote" ), 2 => array( "title" => "The Great Gatsby" ) ); $books_available = array( 0 => array( "title" => "Moby Dick", "count" => 1 ), 1 => array( "title" => "In Search of Lost Time", "count" => 3, ), 2 => array( "title" => "The Great Gatsby", "count" => 7 ), 3 => array( "title" => "War and Peace", "count" => 9 ) ); $sorted_titles = array_column($books_sorted, 'title'); $available_titles = array_reduce($books_available, function($result, $e) { $result[$e['title']] = $e; return $result; }); $third_array = array_merge( array_map( function($e) use ($available_titles) { return array_merge($available_titles[$e['title']], $e); }, array_filter($books_sorted, function($e) use ($available_titles) { return in_array($e['title'], array_keys($available_titles)); }) ), array_filter($books_available, function($e) use ($sorted_titles) { return !in_array($e['title'], $sorted_titles); }) ); print_r($third_array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZGbB
function name:  (null)
number of ops:  40
compiled vars:  !0 = $books_sorted, !1 = $books_available, !2 = $sorted_titles, !3 = $available_titles, !4 = $third_array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   16     1        ASSIGN                                                   !1, <array>
   35     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'title'
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !2, $7
   36     7        INIT_FCALL                                               'array_reduce'
          8        SEND_VAR                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                          ~9      [0]
   39    10        SEND_VAL                                                 ~9
   36    11        DO_ICALL                                         $10     
         12        ASSIGN                                                   !3, $10
   41    13        INIT_FCALL                                               'array_merge'
   42    14        INIT_FCALL                                               'array_map'
   43    15        DECLARE_LAMBDA_FUNCTION                          ~12     [1]
         16        BIND_LEXICAL                                             ~12, !3
   45    17        SEND_VAL                                                 ~12
   46    18        INIT_FCALL                                               'array_filter'
         19        SEND_VAR                                                 !0
         20        DECLARE_LAMBDA_FUNCTION                          ~13     [2]
         21        BIND_LEXICAL                                             ~13, !3
   48    22        SEND_VAL                                                 ~13
   46    23        DO_ICALL                                         $14     
   48    24        SEND_VAR                                                 $14
   42    25        DO_ICALL                                         $15     
   48    26        SEND_VAR                                                 $15
   50    27        INIT_FCALL                                               'array_filter'
         28        SEND_VAR                                                 !1
         29        DECLARE_LAMBDA_FUNCTION                          ~16     [3]
         30        BIND_LEXICAL                                             ~16, !2
   52    31        SEND_VAL                                                 ~16
   50    32        DO_ICALL                                         $17     
   52    33        SEND_VAR                                                 $17
   41    34        DO_ICALL                                         $18     
         35        ASSIGN                                                   !4, $18
   55    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !4
         38        DO_ICALL                                                 
         39      > 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/VZGbB
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $result, !1 = $e
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   37     2        FETCH_DIM_R                                      ~2      !1, 'title'
          3        ASSIGN_DIM                                               !0, ~2
          4        OP_DATA                                                  !1
   38     5      > RETURN                                                   !0
   39     6*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZGbB
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $e, !1 = $available_titles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   44     2        INIT_FCALL                                               'array_merge'
          3        FETCH_DIM_R                                      ~2      !0, 'title'
          4        FETCH_DIM_R                                      ~3      !1, ~2
          5        SEND_VAL                                                 ~3
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
   45     9*     > RETURN                                                   null

End of Dynamic Function 1

Dynamic Function 2
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZGbB
function name:  {closure}
number of ops:  12
compiled vars:  !0 = $e, !1 = $available_titles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   47     2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'title'
          4        SEND_VAL                                                 ~2
          5        INIT_FCALL                                               'array_keys'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $3      
          8        SEND_VAR                                                 $3
          9        DO_ICALL                                         $4      
         10      > RETURN                                                   $4
   48    11*     > RETURN                                                   null

End of Dynamic Function 2

Dynamic Function 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VZGbB
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $e, !1 = $sorted_titles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   51     2        INIT_FCALL                                               'in_array'
          3        FETCH_DIM_R                                      ~2      !0, 'title'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > RETURN                                                   ~4
   52     9*     > RETURN                                                   null

End of Dynamic Function 3

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
162.56 ms | 1031 KiB | 22 Q