3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = json_decode('[{"id":4,"data":"data1"},{"id":14,"data":"data41"},{"id":14,"data":"data14"}]'); $idSearched = 14; function filter($item){ global $idSearched; return $item->id === $idSearched; } $res = array_filter($array, "filter"); print_r($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bGpWF
function name:  (null)
number of ops:  14
compiled vars:  !0 = $array, !1 = $idSearched, !2 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%7B%22id%22%3A4%2C%22data%22%3A%22data1%22%7D%2C%7B%22id%22%3A14%2C%22data%22%3A%22data41%22%7D%2C%7B%22id%22%3A14%2C%22data%22%3A%22data14%22%7D%5D'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
    5     4        ASSIGN                                                   !1, 14
   12     5        INIT_FCALL                                               'array_filter'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 'filter'
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   13    10        INIT_FCALL                                               'print_r'
         11        SEND_VAR                                                 !2
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Function filter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bGpWF
function name:  filter
number of ops:  6
compiled vars:  !0 = $item, !1 = $idSearched
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        BIND_GLOBAL                                              !1, 'idSearched'
    9     2        FETCH_OBJ_R                                      ~2      !0, 'id'
          3        IS_IDENTICAL                                     ~3      !1, ~2
          4      > RETURN                                                   ~3
   10     5*     > RETURN                                                   null

End of function filter

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
291 ms | 1012 KiB | 16 Q