3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr = [ 'status' => 1, 'msg' => [ 'total_records' => 5, 'total_pages' => 1, 'page_number' => 1, 'per_page' => 100, 'return_count' => 5, 'page_result' => [ 0 => [ 'items' => 200052001, 'code' => 501, 'category' => 'watch', 'price' => 50, 'stock' => 1, ], 1 => [ 'items' => 200052001, 'code' => 401, 'category' => 'shirt', 'price' => 3, 'stock' => 1, ], 2 => [ 'items' => 200052001, 'code' => 172758801, 'category' => 'watch', 'price' => 200, 'stock' => 1, ], ], ], 'errcode' => 0, ]; function search($array, $key, $value) { $results = []; if (is_array($array)) { if (isset($array[$key]) && $array[$key] == $value) { $results[] = $array; } foreach ($array as $subarray) { $results = array_merge($results, search($subarray, $key, $value)); } } return $results; } $temp = search($arr, "category", "watch"); print_r($temp);die;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 61) Position 1 = -2
filename:       /in/NrHtV
function name:  (null)
number of ops:  13
compiled vars:  !0 = $arr, !1 = $temp
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   54     1        INIT_FCALL                                                   'search'
          2        SEND_VAR                                                     !0
          3        SEND_VAL                                                     'category'
          4        SEND_VAL                                                     'watch'
          5        DO_FCALL                                          0  $3      
          6        ASSIGN                                                       !1, $3
   55     7        INIT_FCALL                                                   'print_r'
          8        SEND_VAR                                                     !1
          9        DO_ICALL                                                     
         10      > INIT_FCALL                                                   'exit'
         11*       DO_ICALL                                                     
   56    12*     > RETURN                                                       1

Function search:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 28
Branch analysis from position: 6
2 jumps found. (Code = 46) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 27
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 27
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
Branch analysis from position: 14
Branch analysis from position: 11
Branch analysis from position: 28
filename:       /in/NrHtV
function name:  search
number of ops:  30
compiled vars:  !0 = $array, !1 = $key, !2 = $value, !3 = $results, !4 = $subarray
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   39     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   41     3        ASSIGN                                                       !3, <array>
   42     4        TYPE_CHECK                                      128          !0
          5      > JMPZ                                                         ~6, ->28
   43     6    >   ISSET_ISEMPTY_DIM_OBJ                             0  ~7      !0, !1
          7      > JMPZ_EX                                              ~7      ~7, ->11
          8    >   FETCH_DIM_R                                          ~8      !0, !1
          9        IS_EQUAL                                             ~9      !2, ~8
         10        BOOL                                                 ~7      ~9
         11    > > JMPZ                                                         ~7, ->14
   44    12    >   ASSIGN_DIM                                                   !3
         13        OP_DATA                                                      !0
   47    14    > > FE_RESET_R                                           $11     !0, ->27
         15    > > FE_FETCH_R                                                   $11, !4, ->27
   48    16    >   INIT_FCALL                                                   'array_merge'
         17        SEND_VAR                                                     !3
         18        INIT_FCALL_BY_NAME                                           'search'
         19        SEND_VAR_EX                                                  !4
         20        SEND_VAR_EX                                                  !1
         21        SEND_VAR_EX                                                  !2
         22        DO_FCALL                                          0  $12     
         23        SEND_VAR                                                     $12
         24        DO_ICALL                                             $13     
         25        ASSIGN                                                       !3, $13
   47    26      > JMP                                                          ->15
         27    >   FE_FREE                                                      $11
   52    28    > > RETURN                                                       !3
   53    29*     > RETURN                                                       null

End of function search

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.86 ms | 2341 KiB | 17 Q