3v4l.org

run code in 300+ PHP versions simultaneously
<?php $_GET = ['pool' => 1, 'beach' => 1, 'concierge' => 1]; // Created a static array for you guys for debugging // page.php?pool=1&beach=1&concierge=1 put this url path at the end of the url so you can get the data im seeing $htls=array(array("HotelName"=>"M Beach Hotel","minprice"=>264,"CountryCode"=>"US",'feature'=>array("type"=>"hotel","pool"=>1,"beach"=>1,'concierge'=>0)), array("HotelName"=>"Hilton","minprice"=>73,"CountryCode"=>"US",'feature'=>array("type"=>"hotel","pool"=>1,"beach"=>0,'concierge'=>1)), array("HotelName"=>"Fontainebleau","minprice"=>375,"CountryCode"=>"US",'feature'=>array("type"=>"resort","pool"=>1,"beach"=>1,'concierge'=>1)), array("HotelName"=>"Woodlow Inn","minprice"=>40,"CountryCode"=>"US",'feature'=>array("type"=>"inn","pool"=>0,"beach"=>0,'concierge'=>0)), array("HotelName"=>"El cabanna","minprice"=>73,"CountryCode"=>"US",'feature'=>array("type"=>"resort","pool"=>1,"beach"=>1,'concierge'=>1)), array("HotelName"=>"James south beach","minprice"=>73,"CountryCode"=>"US",'feature'=>array("type"=>"hotel","pool"=>0,"beach"=>1,'concierge'=>0)), ); $filtered = array_filter($htls, function($hotel) { return !array_diff_assoc($_GET, $hotel['feature']); }); var_dump($filtered);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ps37G
function name:  (null)
number of ops:  13
compiled vars:  !0 = $htls, !1 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   FETCH_W                      global              $2      '_GET'
          1        ASSIGN                                                   $2, <array>
    7     2        ASSIGN                                                   !0, <array>
   14     3        INIT_FCALL                                               'array_filter'
          4        SEND_VAR                                                 !0
          5        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
   16     6        SEND_VAL                                                 ~5
   14     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !1, $6
   17     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
         12      > 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/Ps37G
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $hotel
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        INIT_FCALL                                               'array_diff_assoc'
          2        FETCH_R                      global              ~1      '_GET'
          3        SEND_VAL                                                 ~1
          4        FETCH_DIM_R                                      ~2      !0, 'feature'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > RETURN                                                   ~4
   16     9*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.68 ms | 1004 KiB | 16 Q