3v4l.org

run code in 300+ PHP versions simultaneously
<?php $products = json_decode('[ { "title": "Product One", "categories": ["one", "two"] }, { "title": "Product Two", "categories": ["two", "three"] }, { "title": "Product Three", "categories": ["three", "four"] } ]'); $result = []; foreach ($products as $row) { if (in_array('two', $row->categories)) { $result[] = $row; } } echo json_encode($result, JSON_PRETTY_PRINT);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/c70S2
function name:  (null)
number of ops:  23
compiled vars:  !0 = $products, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%5B%0A++++%7B+%22title%22%3A+%22Product+One%22%2C+%22categories%22%3A+%5B%22one%22%2C+%22two%22%5D+%7D%2C%0A++++%7B+%22title%22%3A+%22Product+Two%22%2C+%22categories%22%3A+%5B%22two%22%2C+%22three%22%5D+%7D%2C%0A++++%7B+%22title%22%3A+%22Product+Three%22%2C+%22categories%22%3A+%5B%22three%22%2C+%22four%22%5D+%7D%0A%5D'
          2        DO_ICALL                                         $3      
          3        ASSIGN                                                   !0, $3
    9     4        ASSIGN                                                   !1, <array>
   10     5      > FE_RESET_R                                       $6      !0, ->16
          6    > > FE_FETCH_R                                               $6, !2, ->16
   11     7    >   INIT_FCALL                                               'in_array'
          8        SEND_VAL                                                 'two'
          9        FETCH_OBJ_R                                      ~7      !2, 'categories'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                         $8      
         12      > JMPZ                                                     $8, ->15
   12    13    >   ASSIGN_DIM                                               !1
         14        OP_DATA                                                  !2
   10    15    > > JMP                                                      ->6
         16    >   FE_FREE                                                  $6
   15    17        INIT_FCALL                                               'json_encode'
         18        SEND_VAR                                                 !1
         19        SEND_VAL                                                 128
         20        DO_ICALL                                         $10     
         21        ECHO                                                     $10
         22      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.2 ms | 1001 KiB | 16 Q