3v4l.org

run code in 300+ PHP versions simultaneously
<?php $status_key ="status"; $response = '{"error":false,"data":{"id":16420728,"order_id":"5000","mobile_no":"9995088810","amount":20,"balance":46.89,"status":"failure","tnx_id":"","response":"Transaction Failed"}}'; $result = json_decode($response, true); var_dump(findKey($result, $status_key)); function findKey($array, $keySearch) { foreach ($array as $key => $item) { if ($key == $keySearch) { return true; } elseif (is_array($item) && findKey($item, $keySearch)) { return true; } } return false; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KaX9F
function name:  (null)
number of ops:  15
compiled vars:  !0 = $status_key, !1 = $response, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, 'status'
    6     1        ASSIGN                                                   !1, '%7B%22error%22%3Afalse%2C%22data%22%3A%7B%22id%22%3A16420728%2C%22order_id%22%3A%225000%22%2C%22mobile_no%22%3A%229995088810%22%2C%22amount%22%3A20%2C%22balance%22%3A46.89%2C%22status%22%3A%22failure%22%2C%22tnx_id%22%3A%22%22%2C%22response%22%3A%22Transaction+Failed%22%7D%7D'
    8     2        INIT_FCALL                                               'json_decode'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 <true>
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !2, $5
   10     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL_BY_NAME                                       'findKey'
          9        SEND_VAR_EX                                              !2
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0  $7      
         12        SEND_VAR                                                 $7
         13        DO_ICALL                                                 
   22    14      > RETURN                                                   1

Function findkey:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 21
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 17
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 17
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/KaX9F
function name:  findKey
number of ops:  24
compiled vars:  !0 = $array, !1 = $keySearch, !2 = $item, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2      > FE_RESET_R                                       $4      !0, ->21
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->21
          4    >   ASSIGN                                                   !3, ~5
   15     5        IS_EQUAL                                                 !3, !1
          6      > JMPZ                                                     ~7, ->10
   16     7    >   FE_FREE                                                  $4
          8      > RETURN                                                   <true>
   15     9*       JMP                                                      ->20
   17    10    >   TYPE_CHECK                                  128  ~8      !2
         11      > JMPZ_EX                                          ~8      ~8, ->17
         12    >   INIT_FCALL_BY_NAME                                       'findKey'
         13        SEND_VAR_EX                                              !2
         14        SEND_VAR_EX                                              !1
         15        DO_FCALL                                      0  $9      
         16        BOOL                                             ~8      $9
         17    > > JMPZ                                                     ~8, ->20
   18    18    >   FE_FREE                                                  $4
         19      > RETURN                                                   <true>
   14    20    > > JMP                                                      ->3
         21    >   FE_FREE                                                  $4
   21    22      > RETURN                                                   <false>
   22    23*     > RETURN                                                   null

End of function findkey

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.57 ms | 1011 KiB | 15 Q