3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on XrZWV
Output for 7.1.25 - 7.3.2
overview.url