3v4l.org

run code in 300+ PHP versions simultaneously
<?php $books_sorted = array( 0 => array( "title" => "In Search of Lost Time" ), 1 => array( "title" => "Don Quixote" ), 2 => array( "title" => "The Great Gatsby" ) ); $books_available = array( 0 => array( "title" => "Moby Dick" ), 1 => array( "title" => "In Search of Lost Time" ), 2 => array( "title" => "The Great Gatsby" ), 3 => array( "title" => "War and Peace" ) ); $sorted_titles = array_column($books_sorted, 'title'); $available_titles = array_column($books_available, 'title'); $third_array = array_merge( array_filter($books_sorted, function($e) use ($available_titles) { return in_array($e['title'], $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/fSpWm
function name:  (null)
number of ops:  33
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>
   15     1        ASSIGN                                                   !1, <array>
   30     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'title'
          5        DO_ICALL                                         $7      
          6        ASSIGN                                                   !2, $7
   31     7        INIT_FCALL                                               'array_column'
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 'title'
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !3, $9
   33    12        INIT_FCALL                                               'array_merge'
   34    13        INIT_FCALL                                               'array_filter'
         14        SEND_VAR                                                 !0
         15        DECLARE_LAMBDA_FUNCTION                          ~11     [0]
         16        BIND_LEXICAL                                             ~11, !3
   36    17        SEND_VAL                                                 ~11
   34    18        DO_ICALL                                         $12     
   36    19        SEND_VAR                                                 $12
   37    20        INIT_FCALL                                               'array_filter'
         21        SEND_VAR                                                 !1
         22        DECLARE_LAMBDA_FUNCTION                          ~13     [1]
         23        BIND_LEXICAL                                             ~13, !2
   39    24        SEND_VAL                                                 ~13
   37    25        DO_ICALL                                         $14     
   39    26        SEND_VAR                                                 $14
   33    27        DO_ICALL                                         $15     
         28        ASSIGN                                                   !4, $15
   42    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > 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/fSpWm
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $e, !1 = $available_titles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   35     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      > RETURN                                                   $3
   36     8*     > 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/fSpWm
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $e, !1 = $sorted_titles
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   38     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
   39     9*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.03 ms | 1014 KiB | 18 Q