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,11 +74,13 @@ abstract class PatchBase {
|
|||
return false;
|
||||
}
|
||||
protected function parse_json(string $key, string $re = '/(.*)/') : bool {
|
||||
$flat = iterator_to_array(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data)));
|
||||
if (!empty($flat[$key])) {
|
||||
$this->data = $flat[$key];
|
||||
$it = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->data));
|
||||
foreach ($it as $k => $v) {
|
||||
if ($key == $k) {
|
||||
$this->data = $v;
|
||||
return $this->parse($re);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
protected function parse_yaml(string $key, string $re = '/(.*)/') : bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue