3v4l.org

run code in 500+ PHP versions simultaneously
<?php $selectedItems = [ ["ItemId" => "T123", "Price" => "12.00"], ["ItemId" => "T99", "Price" => "13.00"], ]; $orders = [ ["ItemId" => "T123", "Cost" => "12.00"], ["ItemId" => "T99", "Cost" => "13.00"], ["ItemId" => "T33", "Cost" => "13.00"], ]; function checkContainsOrders($selectedItems, $orders) { //Commenting this lines that are necessary only for Laravel Collection //$selectedItems = $selectedItems->toArray(); //$orders = $orders->toArray(); $selectedItemsKeys = array_column($selectedItems, 'ItemId'); $orderItemsKeys = array_column($orders, 'ItemId'); $intersectedValues = array_intersect($selectedItemsKeys, $orderItemsKeys); if (count($intersectedValues) === count($selectedItems) || count($intersectedValues) === count($orders)) { echo 'yup'; } else { echo 'nope'; } } checkContainsOrders($selectedItems, $orders);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JlCC8
function name:  (null)
number of ops:  7
compiled vars:  !0 = $selectedItems, !1 = $orders
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    8     1        ASSIGN                                                       !1, <array>
   32     2        INIT_FCALL                                                   'checkcontainsorders'
          3        SEND_VAR                                                     !0
          4        SEND_VAR                                                     !1
          5        DO_FCALL                                          0          
          6      > RETURN                                                       1

Function checkcontainsorders:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 25
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 28
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/JlCC8
function name:  checkContainsOrders
number of ops:  30
compiled vars:  !0 = $selectedItems, !1 = $orders, !2 = $selectedItemsKeys, !3 = $orderItemsKeys, !4 = $intersectedValues
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   20     2        INIT_FCALL                                                   'array_column'
          3        SEND_VAR                                                     !0
          4        SEND_VAL                                                     'ItemId'
          5        DO_ICALL                                             $5      
          6        ASSIGN                                                       !2, $5
   21     7        INIT_FCALL                                                   'array_column'
          8        SEND_VAR                                                     !1
          9        SEND_VAL                                                     'ItemId'
         10        DO_ICALL                                             $7      
         11        ASSIGN                                                       !3, $7
   23    12        INIT_FCALL                                                   'array_intersect'
         13        SEND_VAR                                                     !2
         14        SEND_VAR                                                     !3
         15        DO_ICALL                                             $9      
         16        ASSIGN                                                       !4, $9
   25    17        COUNT                                                ~11     !4
         18        COUNT                                                ~12     !0
         19        IS_IDENTICAL                                         ~13     ~11, ~12
         20      > JMPNZ_EX                                             ~13     ~13, ->25
         21    >   COUNT                                                ~14     !4
         22        COUNT                                                ~15     !1
         23        IS_IDENTICAL                                         ~16     ~14, ~15
         24        BOOL                                                 ~13     ~16
         25    > > JMPZ                                                         ~13, ->28
   26    26    >   ECHO                                                         'yup'
   25    27      > JMP                                                          ->29
   28    28    >   ECHO                                                         'nope'
   30    29    > > RETURN                                                       null

End of function checkcontainsorders

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.44 ms | 2575 KiB | 16 Q