3v4l.org

run code in 500+ PHP versions simultaneously
<?php function &getRowReference($array, $fn) { foreach ($array as $row) { if ($fn($row)) { return $row->content; } } } function qualifyingRow($row) { global $id; global $type; return $row->id == $id && $row->type == $type; } $id = 54; $type = 55; $array = [ (object)[ "id" => 54, "type" => 5, "content" => [ ["id" => 99, "type" => 516], ["id" => 88, "type" => 464], ["id" => 41, "type" => 845] ] ], (object)[ "id" => 54, "type" => 55, "content" => [ ["id" => 54, "type" => 578], ["id" => 54, "type" => 354], ["id" => 75, "type" => 458] ] ], (object)[ "id" => 65, "type" => 59, "content" => [ ["id" => 87, "type" => 5454], ["id" => 65, "type" => 245], ["id" => 65, "type" => 24525] ] ] ]; $ref = &getRowReference($array, 'qualifyingRow'); $ref = 'this has been changed'; var_export($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/k1KLp
function name:  (null)
number of ops:  19
compiled vars:  !0 = $id, !1 = $type, !2 = $array, !3 = $ref
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                       !0, 54
   18     1        ASSIGN                                                       !1, 55
   22     2        CAST                                              8  ~6      <array>
          3        INIT_ARRAY                                           ~7      ~6
          4        CAST                                              8  ~8      <array>
          5        ADD_ARRAY_ELEMENT                                    ~7      ~8
          6        CAST                                              8  ~9      <array>
          7        ADD_ARRAY_ELEMENT                                    ~7      ~9
   20     8        ASSIGN                                                       !2, ~7
   50     9        INIT_FCALL                                                   'getrowreference'
         10        SEND_VAR                                                     !2
         11        SEND_VAL                                                     'qualifyingRow'
         12        DO_FCALL                                          0  $11     
         13        ASSIGN_REF                                                   !3, $11
   52    14        ASSIGN                                                       !3, 'this+has+been+changed'
   54    15        INIT_FCALL                                                   'var_export'
         16        SEND_VAR                                                     !2
         17        DO_ICALL                                                     
         18      > RETURN                                                       1

Function getrowreference:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 12
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
Return found
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 12
Return found
Branch analysis from position: 12
filename:       /in/k1KLp
function name:  getRowReference
number of ops:  14
compiled vars:  !0 = $array, !1 = $fn, !2 = $row
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    4     2      > FE_RESET_R                                           $3      !0, ->12
          3    > > FE_FETCH_R                                                   $3, !2, ->12
    5     4    >   INIT_DYNAMIC_CALL                                            !1
          5        SEND_VAR_EX                                                  !2
          6        DO_FCALL                                          0  $4      
          7      > JMPZ                                                         $4, ->11
    6     8    >   FETCH_OBJ_W                                          $5      !2, 'content'
          9        FE_FREE                                                      $3
         10      > RETURN_BY_REF                                                $5
    4    11    > > JMP                                                          ->3
         12    >   FE_FREE                                                      $3
    9    13      > RETURN_BY_REF                                                null

End of function getrowreference

Function qualifyingrow:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 6, Position 2 = 9
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/k1KLp
function name:  qualifyingRow
number of ops:  11
compiled vars:  !0 = $row, !1 = $id, !2 = $type
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
   12     1        BIND_GLOBAL                                                  !1, 'id'
   13     2        BIND_GLOBAL                                                  !2, 'type'
   14     3        FETCH_OBJ_R                                          ~3      !0, 'id'
          4        IS_EQUAL                                             ~4      !1, ~3
          5      > JMPZ_EX                                              ~4      ~4, ->9
          6    >   FETCH_OBJ_R                                          ~5      !0, 'type'
          7        IS_EQUAL                                             ~6      !2, ~5
          8        BOOL                                                 ~4      ~6
          9    > > RETURN                                                       ~4
   15    10*     > RETURN                                                       null

End of function qualifyingrow

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.21 ms | 2149 KiB | 15 Q