PatchBase: JSON iterator returns first hit
This commit is contained in:
parent
444ab7f26a
commit
405fe950b8
1 changed files with 6 additions and 4 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue