3v4l.org

run code in 300+ PHP versions simultaneously
<?php $books_sorted = [ ["title" => "In Search of Lost Time", 'others' => 'unuseful1'], ["title" => "Don Quixote", 'others' => 'unuseful2'], ["title" => "The Great Gatsby", 'others' => 'unuseful3'] ]; $books_available = [ ["title" => "Moby Dick", 'others' => 'unuseful4'], ["title" => "In Search of Lost Time", 'others' => 'unuseful5'], ["title" => "The Great Gatsby", 'others' => 'unuseful6'], ["title" => "War and Peace", 'others' => 'unuseful7'] ]; $available = array_column($books_available, 'title'); $result = []; foreach ($books_sorted as $row) { if (($index = array_search($row['title'], $available)) !== false) { $result[] = $row; unset($books_available[$index]); } } array_push($result, ...$books_available); var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 22
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 22
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 21
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 21
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/8koFT
function name:  (null)
number of ops:  32
compiled vars:  !0 = $books_sorted, !1 = $books_available, !2 = $available, !3 = $result, !4 = $row, !5 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   16     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 'title'
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !2, $8
   17     7        ASSIGN                                                   !3, <array>
   18     8      > FE_RESET_R                                       $11     !0, ->22
          9    > > FE_FETCH_R                                               $11, !4, ->22
   19    10    >   INIT_FCALL                                               'array_search'
         11        FETCH_DIM_R                                      ~12     !4, 'title'
         12        SEND_VAL                                                 ~12
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $13     
         15        ASSIGN                                           ~14     !5, $13
         16        TYPE_CHECK                                  1018          ~14
         17      > JMPZ                                                     ~15, ->21
   20    18    >   ASSIGN_DIM                                               !3
         19        OP_DATA                                                  !4
   21    20        UNSET_DIM                                                !1, !5
   18    21    > > JMP                                                      ->9
         22    >   FE_FREE                                                  $11
   24    23        INIT_FCALL                                               'array_push'
         24        SEND_REF                                                 !3
         25        SEND_UNPACK                                              !1
         26        CHECK_UNDEF_ARGS                                         
         27        DO_ICALL                                                 
   25    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.64 ms | 1014 KiB | 17 Q