PHP 8.5.0 Alpha 4 available for testing

Voting

: min(eight, eight)?
(Example: nine)

The Note You're Voting On

ohcc at 163 dot com
2 years ago
You can remove SimpleXMLElement nodes using php's unset() language construct.

<?php
$xml
= <<<'EOT'
<users>
<user>
<name>orange</name>
<sex>male</sex>
<homepage>wuxiancheng.cn</homepage>
</user>
<user>
<name>tangerine</name>
<sex>male</sex>
<homepage>51-n.com</homepage>
</user>
</users>
EOT;
$sxe = new SimpleXMLElement($xml);
// This will remove the first user node
unset($sxe->user[0]);
// This will remove all user nodes
unset($sxe->user);
echo
$sxe->asXML();
?>

<< Back to user notes page

To Top