3v4l.org

run code in 300+ PHP versions simultaneously
<?php $category = array( 1 => array( 'id' => 1, 'parentID' => 0, 'name' => 'SUV auto parts' ), 2 => array( 'id' => 2, 'parentID' => 1, 'name' => 'Engine Related' ), 3 => array( 'id' => 3, 'parentID' => 2, 'name' => 'Spark Plugs' ), 4 => array( 'id' => 4, 'parentID' => 2, 'name' => 'Engine Oil' ), 5 => array( 'id' => 5, 'parentID' => 1, 'name' => 'Body related' ), 6 => array( 'id' => 6, 'parentID' => 0, 'name' => 'Sedan auto parts' ), 7 => array( 'id' => 7, 'parentID' => 6, 'name' => 'Engine Related' ), ); $parentId = 2; // set the parentID foreach($category as $key => $value) { if($value['parentID'] == $parentId) { echo '<pre>'; print_r($value); // print matching records echo '</pre>'; } }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 13
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/TUhvX
function name:  (null)
number of ops:  16
compiled vars:  !0 = $category, !1 = $parentId, !2 = $value, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   41     1        ASSIGN                                                   !1, 2
   43     2      > FE_RESET_R                                       $6      !0, ->14
          3    > > FE_FETCH_R                                       ~7      $6, !2, ->14
          4    >   ASSIGN                                                   !3, ~7
   44     5        FETCH_DIM_R                                      ~9      !2, 'parentID'
          6        IS_EQUAL                                                 !1, ~9
          7      > JMPZ                                                     ~10, ->13
   45     8    >   ECHO                                                     '%3Cpre%3E'
   46     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
   47    12        ECHO                                                     '%3C%2Fpre%3E'
   43    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $6
   49    15      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.11 ms | 999 KiB | 14 Q