3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{"id": 10, "title": "book"},{"id": 24,"title": "cars"},{"id": 52, "title": "houses"}]'; $array = json_decode($json,1); $title = 'cars'; $result = array_filter($array, function ($element) use ($title) { return ($element['title'] == $title); }); echo array_column($result,'id')[0]; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MgKIL
function name:  (null)
number of ops:  21
compiled vars:  !0 = $json, !1 = $array, !2 = $title, !3 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%5B%7B%22id%22%3A+10%2C+%22title%22%3A+%22book%22%7D%2C%7B%22id%22%3A+24%2C%22title%22%3A+%22cars%22%7D%2C%7B%22id%22%3A+52%2C++++%22title%22%3A+%22houses%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, 'cars'
    5     7        INIT_FCALL                                               'array_filter'
          8        SEND_VAR                                                 !1
          9        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
         10        BIND_LEXICAL                                             ~8, !2
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13        ASSIGN                                                   !3, $9
    6    14        INIT_FCALL                                               'array_column'
         15        SEND_VAR                                                 !3
         16        SEND_VAL                                                 'id'
         17        DO_ICALL                                         $11     
         18        FETCH_DIM_R                                      ~12     $11, 0
         19        ECHO                                                     ~12
    8    20      > 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/MgKIL
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $element, !1 = $title
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        FETCH_DIM_R                                      ~2      !0, 'title'
          3        IS_EQUAL                                         ~3      !1, ~2
          4      > RETURN                                                   ~3
          5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.92 ms | 1013 KiB | 16 Q