PatchBase: JSON iterator returns first hit

This commit is contained in:
Steffen Lange 2021-10-24 00:26:57 +02:00
parent 444ab7f26a
commit 405fe950b8

View file

@ -74,10 +74,12 @@ abstract class PatchBase {
return false; return false;
} }
protected function parse_json(string $key, string $re = '/(.*)/') : bool { protected function parse_json(string $key, string $re = '/(.*)/') : bool {
$flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data))); $it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data));
if (!empty($flat[$key])) { foreach ($it as $k => $v) {
$this->data = $flat[$key]; if ($key == $k) {
return $this->parse($re); $this->data = $v;
return $this->parse($re);
}
} }
return false; return false;
} }