hdf_set_node — Set the tree structure of a node
bool hdf_set_node( | hdf, | |
name, | ||
node) ; |
resource hdf
;string name
;mixed node
;
Sets node
to be a child node of HDF resource hdf
. name
determines where node
will be added. If a node of the same top level name exists then it overwritten, otherwise the new node is appended. Returns true on success, false on failure. node
can be one of:
value
is copied to the new node. In this case value
need not be a node of hdf
and as such is a useful way of copying HDF datasets.
Example 11. hdf_set_node
using an HDF resource
<?php $hdf = hdf_init(); $another_hdf = hdf_init(); $hdf_str = 'Poem { Author = Mrs Sarah Joseph Hale Year = 1830 Origin = Boston Verse << EOM Mary had a little lamb, Its fleece was white as snow. And everywhere that Mary went, The lamb was sure to go. EOM }'; // populate an HDF hdf_read_string($hdf, $hdf_str); // copy one HDF to another hdf_set_node($another_hdf, '', $hdf); // copy it again to another location hdf_set_node($another_hdf, 'Copy', $hdf); print hdf_write_string($another_hdf); ?>
Example 12. hdf_set_node
using an array
<?php $hdf = hdf_init(); $array = array('null' => null, 'bool' => array('true' => true, 'false'=> false), 'integer' => array('positive' => 100, 'negative' => -72), 'float.positive' => 0.5321, // you can still use dotted notation 'float.negative' => -79.94134, 'string' => 'Getting the picture?'); hdf_set_node($hdf, 'my.key', $array); print hdf_write_string($hdf); ?>