PHP 8.5.0 Alpha 4 available for testing

Voting

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

The Note You're Voting On

xxxargonxxx at gmail dot com
8 years ago
See previous two parts to get better understanding of how these tricks works. Example shown here refers to part two. (Sorry, length limitation)

3. Tricks
<?php
// The real profit is in combination of property and array accesses and unset($someNode->{0}) trick -
// it allows you to remove whatever node you want:
unset($rootNode->{'div'}[2]); // remove node with * mark (text*)

// Another trick is removing child node using child node object
$newChildNode = $rootNode->addChild('div','text**'); // Create
unset($newChildNode->{0}); // Remove, node removed from parent object too!

echo "--2--\n".$rootNode->asXML();
/*
<xml_root>complex node
<type_one>renewed node 1</type_one>
<type_two>node 3</type_two>
<type_one>node 2</type_one>
<div>text</div>
<div>text</div>
<div>text</div>
</xml_root>
*/
?>

<< Back to user notes page

To Top