(PHP 8 >= 8.3.0)
DOMNode::contains — Checks if node contains other node
Checks if node contains other
node.
other
Node to be checked.
Example #1 DOMNode::contains() example
<?php
$dom = new DOMDocument();
$dom->loadXML(<<<XML
<!DOCTYPE HTML>
<html>
<body>
<main>
<p>Hello, world!</p>
</main>
</body>
</html>
XML);
$xpath = new DOMXPath($dom);
$main = $xpath->query("/main")[0];
var_dump($dom->documentElement->contains($main));
?>
The above example will output:
bool(true)
Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!
Check out: eBank.nz (Art Generator) |
Netwrck.com (AI Tools) |
Text-Generator.io (AI API) |
BitBank.nz (Crypto AI) |
ReadingTime (Kids Reading) |
RewordGame |
BigMultiplayerChess |
WebFiddle |
How.nz |
Helix AI Assistant