3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{"name":"Juan","Sex":"Male","ID":"1100"},{"name":"Maria","Sex":"Female","ID":"2513"},{"name":"Pedro","Sex":"Male","ID":"2211"}]'; $array = json_decode($json,1); $ID = 2513; $expected = array_filter($array, function ($var) use ($ID) { return ($var['ID'] == $ID); }); print_r($expected); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kZrMo
function name:  (null)
number of ops:  18
compiled vars:  !0 = $json, !1 = $array, !2 = $ID, !3 = $expected
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5B%7B%22name%22%3A%22Juan%22%2C%22Sex%22%3A%22Male%22%2C%22ID%22%3A%221100%22%7D%2C%7B%22name%22%3A%22Maria%22%2C%22Sex%22%3A%22Female%22%2C%22ID%22%3A%222513%22%7D%2C%7B%22name%22%3A%22Pedro%22%2C%22Sex%22%3A%22Male%22%2C%22ID%22%3A%222211%22%7D%5D'
    3     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    4     6        ASSIGN                                                   !2, 2513
    5     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
         10        BIND_LEXICAL                                             ~8, !2
    7    11        SEND_VAL                                                 ~8
    5    12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !3, $9
    8    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !3
         16        DO_ICALL                                                 
    9    17      > 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/kZrMo
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $var, !1 = $ID
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        FETCH_DIM_R                                      ~2      !0, 'ID'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
    7     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.23 ms | 1002 KiB | 16 Q