3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cart_items = '[ {"id":8, "cart_id":7, "product_id":4, "variation_id":null, "quantity":1, "price":30, "tax":0, "attrs":null, "gross_total":30, "net_total":30, "tax_total":0, "product":{ "id":4, "parent_id":null, "category_id":1, "shop_id":1, "title":"Ladies Blazer", "unit":"item", "sale_price":30, "general_price":35 } }, { "id":9, "cart_id":7, "product_id":1, "variation_id":null, "quantity":2, "price":11, "tax":0, "attrs":null, "gross_total":22, "net_total":22, "tax_total":0, "product":{ "id":1, "parent_id":null, "category_id":2, "shop_id":2, "title":"Sport Bottles", "unit":"item", "sale_price":11, "general_price":9 } } ]'; $arr = json_decode($cart_items, true); $shop_id = 1; $result = array_filter($arr, fn($v) => $v["product"]["shop_id"] == $shop_id); var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/19gnD
function name:  (null)
number of ops:  18
compiled vars:  !0 = $cart_items, !1 = $arr, !2 = $shop_id, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%0A++++%7B%22id%22%3A8%2C%0A++++%22cart_id%22%3A7%2C%0A++++%22product_id%22%3A4%2C%0A++++%22variation_id%22%3Anull%2C%0A++++%22quantity%22%3A1%2C%0A++++%22price%22%3A30%2C%0A++++%22tax%22%3A0%2C%0A++++%22attrs%22%3Anull%2C%0A++++%22gross_total%22%3A30%2C%0A++++%22net_total%22%3A30%2C%0A++++%22tax_total%22%3A0%2C%0A++++%22product%22%3A%7B%0A++++++++%22id%22%3A4%2C%0A++++++++%22parent_id%22%3Anull%2C%0A++++++++%22category_id%22%3A1%2C%0A++++++++%22shop_id%22%3A1%2C%0A++++++++%22title%22%3A%22Ladies+Blazer%22%2C%0A++++++++%22unit%22%3A%22item%22%2C%0A++++++++%22sale_price%22%3A30%2C%0A++++++++%22general_price%22%3A35%0A++++++++%7D%0A++++%7D%2C%0A++++%7B%0A++++%22id%22%3A9%2C%0A++++%22cart_id%22%3A7%2C%0A++++%22product_id%22%3A1%2C%0A++++%22variation_id%22%3Anull%2C%0A++++%22quantity%22%3A2%2C%0A++++%22price%22%3A11%2C%0A++++%22tax%22%3A0%2C%0A++++%22attrs%22%3Anull%2C%0A++++%22gross_total%22%3A22%2C%0A++++%22net_total%22%3A22%2C%0A++++%22tax_total%22%3A0%2C%0A++++%22product%22%3A%7B%0A++++++++%22id%22%3A1%2C%0A++++++++%22parent_id%22%3Anull%2C%0A++++++++%22category_id%22%3A2%2C%0A++++++++%22shop_id%22%3A2%2C%0A++++++++%22title%22%3A%22Sport+Bottles%22%2C%0A++++++++%22unit%22%3A%22item%22%2C%0A++++++++%22sale_price%22%3A11%2C%0A++++++++%22general_price%22%3A9%0A++++++++%7D%0A++++%7D%0A%5D'
   51     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   53     6        ASSIGN                                                   !2, 1
   54     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F19gnD%3A54%240'
         10        BIND_LEXICAL                                             ~8, !2
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !3, $9
   56    14        INIT_FCALL                                               'var_export'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F19gnD%3A54%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/19gnD
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $v, !1 = $shop_id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   54     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'product'
          3        FETCH_DIM_R                                      ~3      ~2, 'shop_id'
          4        IS_EQUAL                                         ~4      !1, ~3
          5      > RETURN                                                   ~4
          6*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F19gnD%3A54%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.15 ms | 1405 KiB | 19 Q