DOMChildNode::remove

(PHP 8)

DOMChildNode::remove โ€” ใƒŽใƒผใƒ‰ใ‚’ๅ‰Š้™คใ™ใ‚‹

่ชฌๆ˜Ž

public function DOMChildNode::remove(): void

ใƒŽใƒผใƒ‰ใ‚’ๅ‰Š้™คใ—ใพใ™ใ€‚

ใƒ‘ใƒฉใƒกใƒผใ‚ฟ

ใ“ใฎ้–ขๆ•ฐใซใฏใƒ‘ใƒฉใƒกใƒผใ‚ฟใฏใ‚ใ‚Šใพใ›ใ‚“ใ€‚

ๆˆปใ‚Šๅ€ค

ๅ€คใ‚’่ฟ”ใ—ใพใ›ใ‚“ใ€‚

ๅ‚่€ƒ

  • DOMChildNode::after() - ใƒŽใƒผใƒ‰ใฎๅพŒใ‚ใซใƒŽใƒผใƒ‰ใ‚’่ฟฝๅŠ ใ™ใ‚‹
  • DOMChildNode::before() - ใƒŽใƒผใƒ‰ใฎๅ‰ใซใƒŽใƒผใƒ‰ใ‚’่ฟฝๅŠ ใ™ใ‚‹
  • DOMChildNode::replaceWith() - ใƒŽใƒผใƒ‰ใ‚’ๆ–ฐใ—ใ„ใƒŽใƒผใƒ‰ใง็ฝฎใๆ›ใˆใ‚‹
  • DOMNode::removeChild() - ๅญ่ฆ็ด ็พคใ‹ใ‚‰ๅญ่ฆ็ด ใ‚’ๅ‰Š้™คใ™ใ‚‹
๏ผ‹add a note

User Contributed Notes 1 note

up
0
kevin dot sours at internetbrands dot com ยถ
1 year ago
Removing a nodes in a loop over a dom structure can break the iterator so
foreach ($element->childNodes AS $child)
{
  $child->remove();
}

isn't going to do what it looks like it should.  The loop body will only run once regardless of how many children exist.