3v4l.org

run code in 300+ PHP versions simultaneously
<?php $api_response = '{"count":3,"links":[{"id":1001,"name":"Link 1","title":"Link Title","head":"Links","pic":"https://image.com/pic.jpg","views":"10,000+","country":"US"},{"id":1002,"name":"Link 2","title":"Link Title 2","head":"Links","pic":"https://image.com/pic.jpg","views":"10,000+","country":"US"},{"id":1003,"name":"Link 3","title":"Link Title 3","head":"Links","pic":"https://image.com/pic.jpg","views":"10,000+","country":"US"}]}'; $filter = [1001,1003]; $links = json_decode($api_response)->links; $filtered = array_filter($links, function ($item) use ($filter) { return in_array($item->id, $filter); }); print_r($filtered); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNotG
function name:  (null)
number of ops:  18
compiled vars:  !0 = $api_response, !1 = $filter, !2 = $links, !3 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%7B%22count%22%3A3%2C%22links%22%3A%5B%7B%22id%22%3A1001%2C%22name%22%3A%22Link+1%22%2C%22title%22%3A%22Link+Title%22%2C%22head%22%3A%22Links%22%2C%22pic%22%3A%22https%3A%2F%2Fimage.com%2Fpic.jpg%22%2C%22views%22%3A%2210%2C000%2B%22%2C%22country%22%3A%22US%22%7D%2C%7B%22id%22%3A1002%2C%22name%22%3A%22Link+2%22%2C%22title%22%3A%22Link+Title+2%22%2C%22head%22%3A%22Links%22%2C%22pic%22%3A%22https%3A%2F%2Fimage.com%2Fpic.jpg%22%2C%22views%22%3A%2210%2C000%2B%22%2C%22country%22%3A%22US%22%7D%2C%7B%22id%22%3A1003%2C%22name%22%3A%22Link+3%22%2C%22title%22%3A%22Link+Title+3%22%2C%22head%22%3A%22Links%22%2C%22pic%22%3A%22https%3A%2F%2Fimage.com%2Fpic.jpg%22%2C%22views%22%3A%2210%2C000%2B%22%2C%22country%22%3A%22US%22%7D%5D%7D'
    4     1        ASSIGN                                                   !1, <array>
    5     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        FETCH_OBJ_R                                      ~7      $6, 'links'
          6        ASSIGN                                                   !2, ~7
    6     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !2
          9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBNotG%3A6%240'
         10        BIND_LEXICAL                                             ~9, !1
    8    11        SEND_VAL                                                 ~9
         12        DO_ICALL                                         $10     
    6    13        ASSIGN                                                   !3, $10
   10    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
   11    17      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBNotG%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BNotG
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $item, !1 = $filter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    7     2        INIT_FCALL                                               'in_array'
          3        FETCH_OBJ_R                                      ~2      !0, 'id'
          4        SEND_VAL                                                 ~2
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $3      
          7      > RETURN                                                   $3
    8     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBNotG%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
131.93 ms | 1401 KiB | 21 Q