3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => [ "room_id" => "1", "date" => "01-07-2022", "available" => "A" ], 1 => [ "room_id" => "2", "date" => "01-07-2022", "available" => "A" ], 2 => [ "room_id" => "1", "date" => "02-07-2022", "available" => "A" ], 3 => [ "room_id" => "2", "date" => "02-07-2022", "available" => "U" ], 4 => [ "room_id" => "1", "date" => "03-07-2022", "available" => "U" ], 5 => [ "room_id" => "2", "date" => "03-07-2022", "available" => "U" ], 6 => [ "room_id" => "1", "date" => "04-07-2022", "available" => "U" ], ]; $hasVacancy = []; $hasNoVacancy = []; foreach ($array as $row) { if ($row['available'] === 'A') { $hasVacancy[$row['date']] = $row; } else { $hasNoVacancy[$row['date']] = $row; } } var_export(array_values($hasVacancy)); echo "\n---\n"; var_export( array_values(array_diff_key($hasNoVacancy, $hasVacancy)) );
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/ADp86
function name:  (null)
number of ops:  35
compiled vars:  !0 = $array, !1 = $hasVacancy, !2 = $hasNoVacancy, !3 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   41     1        ASSIGN                                                   !1, <array>
   42     2        ASSIGN                                                   !2, <array>
   43     3      > FE_RESET_R                                       $7      !0, ->16
          4    > > FE_FETCH_R                                               $7, !3, ->16
   44     5    >   FETCH_DIM_R                                      ~8      !3, 'available'
          6        IS_IDENTICAL                                             ~8, 'A'
          7      > JMPZ                                                     ~9, ->12
   45     8    >   FETCH_DIM_R                                      ~10     !3, 'date'
          9        ASSIGN_DIM                                               !1, ~10
         10        OP_DATA                                                  !3
   44    11      > JMP                                                      ->15
   47    12    >   FETCH_DIM_R                                      ~12     !3, 'date'
         13        ASSIGN_DIM                                               !2, ~12
         14        OP_DATA                                                  !3
   43    15    > > JMP                                                      ->4
         16    >   FE_FREE                                                  $7
   50    17        INIT_FCALL                                               'var_export'
         18        INIT_FCALL                                               'array_values'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $14     
         21        SEND_VAR                                                 $14
         22        DO_ICALL                                                 
   52    23        ECHO                                                     '%0A---%0A'
   54    24        INIT_FCALL                                               'var_export'
   55    25        INIT_FCALL                                               'array_values'
         26        INIT_FCALL                                               'array_diff_key'
         27        SEND_VAR                                                 !2
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $16     
         30        SEND_VAR                                                 $16
         31        DO_ICALL                                         $17     
         32        SEND_VAR                                                 $17
   54    33        DO_ICALL                                                 
   56    34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.42 ms | 1008 KiB | 16 Q