Skip to content

Commit cfb7aaf

Browse files
committed
Fix Instead of an offset in the list of children, the index of the child was used
1 parent ed0900c commit cfb7aaf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Parserus.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* @copyright Copyright (c) 2016-2022 Visman. All rights reserved.
4+
* @copyright Copyright (c) 2016-2023 Visman. All rights reserved.
55
* @author Visman <mio.visman@yandex.ru>
66
* @link https://github.com/MioVisman/Parserus
77
* @license https://opensource.org/licenses/MIT The MIT License (MIT)
@@ -1268,7 +1268,8 @@ protected function detect(string $tag, string $pattern, bool $textOnly): self
12681268
return $this;
12691269
}
12701270

1271-
$idx = array_search($id, $this->data[$pid]['children']);
1271+
$key = array_search($id, $this->data[$pid]['children']);
1272+
$idx = array_search($key, array_keys($this->data[$pid]['children']));
12721273
$arrEnd = array_slice($this->data[$pid]['children'], $idx + 1);
12731274
$this->data[$pid]['children'] = array_slice($this->data[$pid]['children'], 0, $idx);
12741275

@@ -1284,6 +1285,7 @@ protected function detect(string $tag, string $pattern, bool $textOnly): self
12841285
}
12851286

12861287
$this->addTextNode((string) substr($this->data[$id]['text'], $pos), $pid);
1288+
12871289
unset($this->data[$id]);
12881290

12891291
$this->data[$pid]['children'] = array_merge($this->data[$pid]['children'], $arrEnd);

0 commit comments

Comments
 (0)