3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = '{"uuid":"8888888888888","templateUuid":"001","trashed":"N","createdAt":"2018-09-05T07:52:37Z","updatedAt":"2019-01-24T18:45:35Z","changerUuid":"HHHHHHHHHHHHHH","itemVersion":7,"vaultUuid":"VVVVVVVVVVVVVVVVV","details":{"fields":[{"designation":"username","name":"username","type":"T","value":"33333333333333333333333333"},{"designation":"password","name":"password","type":"P","value":"9999999999999999999999999"}],"notesPlain":"aa","sections":[{"fields":[{"k":"concealed","n":"fffffffffffffffff","t":"custom","v":"something"}],"name":"Section_acydazbajjhifgnahiej3wdrxi","title":""}]},"overview":{"URLs":[{"l":"website","u":"https://api.example.com/"}],"ainfo":"33453ff2e19203cacb35dac4b304f4d3e69020a8","pbe":0,"pgrng":false,"ps":100,"tags":[],"title":"EXAMPLE API KEY","url":"https://api.example.com/"}}'; //echo print_r(json_decode($array, true), true); function findPath($array, $targetKey, $targetValue, $path = []) : ? string { if (!is_array($array)) { $array = json_decode($array, true); } foreach ($array as $key => $value) { if ($key === $targetKey && $value === $targetValue) { $path[] = $key; return implode('.', $path); } } foreach ($array as $key => $value) { if (is_array($value)) { $path[] = $key; if (($result = findPath($value, $targetKey, $targetValue, $path)) !== null) { return $result; } else { array_pop($path); } } } return null; } echo print_r(findPath($array, 'url', 'https://api.example.com/'), true);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/A7J8p
function name:  (null)
number of ops:  12
compiled vars:  !0 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22uuid%22%3A%228888888888888%22%2C%22templateUuid%22%3A%22001%22%2C%22trashed%22%3A%22N%22%2C%22createdAt%22%3A%222018-09-05T07%3A52%3A37Z%22%2C%22updatedAt%22%3A%222019-01-24T18%3A45%3A35Z%22%2C%22changerUuid%22%3A%22HHHHHHHHHHHHHH%22%2C%22itemVersion%22%3A7%2C%22vaultUuid%22%3A%22VVVVVVVVVVVVVVVVV%22%2C%22details%22%3A%7B%22fields%22%3A%5B%7B%22designation%22%3A%22username%22%2C%22name%22%3A%22username%22%2C%22type%22%3A%22T%22%2C%22value%22%3A%2233333333333333333333333333%22%7D%2C%7B%22designation%22%3A%22password%22%2C%22name%22%3A%22password%22%2C%22type%22%3A%22P%22%2C%22value%22%3A%229999999999999999999999999%22%7D%5D%2C%22notesPlain%22%3A%22aa%22%2C%22sections%22%3A%5B%7B%22fields%22%3A%5B%7B%22k%22%3A%22concealed%22%2C%22n%22%3A%22fffffffffffffffff%22%2C%22t%22%3A%22custom%22%2C%22v%22%3A%22something%22%7D%5D%2C%22name%22%3A%22Section_acydazbajjhifgnahiej3wdrxi%22%2C%22title%22%3A%22%22%7D%5D%7D%2C%22overview%22%3A%7B%22URLs%22%3A%5B%7B%22l%22%3A%22website%22%2C%22u%22%3A%22https%3A%2F%2Fapi.example.com%2F%22%7D%5D%2C%22ainfo%22%3A%2233453ff2e19203cacb35dac4b304f4d3e69020a8%22%2C%22pbe%22%3A0%2C%22pgrng%22%3Afalse%2C%22ps%22%3A100%2C%22tags%22%3A%5B%5D%2C%22title%22%3A%22EXAMPLE+API+KEY%22%2C%22url%22%3A%22https%3A%2F%2Fapi.example.com%2F%22%7D%7D'
   33     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'findpath'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'url'
          5        SEND_VAL                                                 'https%3A%2F%2Fapi.example.com%2F'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $3      
         10        ECHO                                                     $3
         11      > RETURN                                                   1

Function findpath:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 30
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 55
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 55
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 54
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 51
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 54
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 30
Branch analysis from position: 12
filename:       /in/A7J8p
function name:  findPath
number of ops:  59
compiled vars:  !0 = $array, !1 = $targetKey, !2 = $targetValue, !3 = $path, !4 = $value, !5 = $key, !6 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV_INIT                                        !3      <array>
    9     4        TYPE_CHECK                                  128  ~7      !0
          5        BOOL_NOT                                         ~8      ~7
          6      > JMPZ                                                     ~8, ->12
   10     7    >   INIT_FCALL                                               'json_decode'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 <true>
         10        DO_ICALL                                         $9      
         11        ASSIGN                                                   !0, $9
   12    12    > > FE_RESET_R                                       $11     !0, ->30
         13    > > FE_FETCH_R                                       ~12     $11, !4, ->30
         14    >   ASSIGN                                                   !5, ~12
   13    15        IS_IDENTICAL                                     ~14     !5, !1
         16      > JMPZ_EX                                          ~14     ~14, ->19
         17    >   IS_IDENTICAL                                     ~15     !4, !2
         18        BOOL                                             ~14     ~15
         19    > > JMPZ                                                     ~14, ->29
   14    20    >   ASSIGN_DIM                                               !3
         21        OP_DATA                                                  !5
   15    22        INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 '.'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $17     
         26        VERIFY_RETURN_TYPE                                       $17
         27        FE_FREE                                                  $11
         28      > RETURN                                                   $17
   12    29    > > JMP                                                      ->13
         30    >   FE_FREE                                                  $11
   19    31      > FE_RESET_R                                       $18     !0, ->55
         32    > > FE_FETCH_R                                       ~19     $18, !4, ->55
         33    >   ASSIGN                                                   !5, ~19
   20    34        TYPE_CHECK                                  128          !4
         35      > JMPZ                                                     ~21, ->54
   21    36    >   ASSIGN_DIM                                               !3
         37        OP_DATA                                                  !5
   22    38        INIT_FCALL_BY_NAME                                       'findPath'
         39        SEND_VAR_EX                                              !4
         40        SEND_VAR_EX                                              !1
         41        SEND_VAR_EX                                              !2
         42        SEND_VAR_EX                                              !3
         43        DO_FCALL                                      0  $23     
         44        ASSIGN                                           ~24     !6, $23
         45        TYPE_CHECK                                  1020          ~24
         46      > JMPZ                                                     ~25, ->51
   23    47    >   VERIFY_RETURN_TYPE                                       !6
         48        FE_FREE                                                  $18
         49      > RETURN                                                   !6
         50*       JMP                                                      ->54
   25    51    >   INIT_FCALL                                               'array_pop'
         52        SEND_REF                                                 !3
         53        DO_ICALL                                                 
   19    54    > > JMP                                                      ->32
         55    >   FE_FREE                                                  $18
   30    56      > RETURN                                                   null
   31    57*       VERIFY_RETURN_TYPE                                       
         58*     > RETURN                                                   null

End of function findpath

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.68 ms | 1411 KiB | 22 Q