3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( json_decode('{"name": "foo1", "other": "test"}'), json_decode('{"name": "foo2", "other": "test"}'), json_decode('{"name": "foo3", "other": "test"}'), ); $name = 'foo2'; echo "INPUT\n", str_repeat('=', 20), "\n"; var_dump($input); echo "\n"; echo "RESULT\n", str_repeat('=', 20), "\n"; var_dump( $result = array_filter($input, function($o) use ($name) { return $o->name == $name; }) ); echo "usage\n", str_repeat('=', 20), "\n"; $match = array_pop($result); var_dump($match->other);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pn6lr
function name:  (null)
number of ops:  58
compiled vars:  !0 = $input, !1 = $name, !2 = $result, !3 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%7B%22name%22%3A+%22foo1%22%2C+%22other%22%3A+%22test%22%7D'
          2        DO_ICALL                                         $4      
          3        INIT_ARRAY                                       ~5      $4
    7     4        INIT_FCALL                                               'json_decode'
          5        SEND_VAL                                                 '%7B%22name%22%3A+%22foo2%22%2C+%22other%22%3A+%22test%22%7D'
          6        DO_ICALL                                         $6      
          7        ADD_ARRAY_ELEMENT                                ~5      $6
    8     8        INIT_FCALL                                               'json_decode'
          9        SEND_VAL                                                 '%7B%22name%22%3A+%22foo3%22%2C+%22other%22%3A+%22test%22%7D'
         10        DO_ICALL                                         $7      
         11        ADD_ARRAY_ELEMENT                                ~5      $7
    5    12        ASSIGN                                                   !0, ~5
   11    13        ASSIGN                                                   !1, 'foo2'
   13    14        ECHO                                                     'INPUT%0A'
         15        INIT_FCALL                                               'str_repeat'
         16        SEND_VAL                                                 '%3D'
         17        SEND_VAL                                                 20
         18        DO_ICALL                                         $10     
         19        ECHO                                                     $10
         20        ECHO                                                     '%0A'
   14    21        INIT_FCALL                                               'var_dump'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                                 
   15    24        ECHO                                                     '%0A'
   16    25        ECHO                                                     'RESULT%0A'
         26        INIT_FCALL                                               'str_repeat'
         27        SEND_VAL                                                 '%3D'
         28        SEND_VAL                                                 20
         29        DO_ICALL                                         $12     
         30        ECHO                                                     $12
         31        ECHO                                                     '%0A'
   17    32        INIT_FCALL                                               'var_dump'
   18    33        INIT_FCALL                                               'array_filter'
         34        SEND_VAR                                                 !0
         35        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Fpn6lr%3A18%240'
         36        BIND_LEXICAL                                             ~13, !1
         37        SEND_VAL                                                 ~13
         38        DO_ICALL                                         $14     
         39        ASSIGN                                           ~15     !2, $14
         40        SEND_VAL                                                 ~15
         41        DO_ICALL                                                 
   21    42        ECHO                                                     'usage%0A'
         43        INIT_FCALL                                               'str_repeat'
         44        SEND_VAL                                                 '%3D'
         45        SEND_VAL                                                 20
         46        DO_ICALL                                         $17     
         47        ECHO                                                     $17
         48        ECHO                                                     '%0A'
   23    49        INIT_FCALL                                               'array_pop'
         50        SEND_REF                                                 !2
         51        DO_ICALL                                         $18     
         52        ASSIGN                                                   !3, $18
   24    53        INIT_FCALL                                               'var_dump'
         54        FETCH_OBJ_R                                      ~20     !3, 'other'
         55        SEND_VAL                                                 ~20
         56        DO_ICALL                                                 
         57      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2Fpn6lr%3A18%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.02 ms | 1400 KiB | 23 Q