PHP current() Function

❮ PHP SimpleXML Reference

Example

Rewind to the first element and then return it with the current() function:

<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Do not forget me this weekend!</body>
</note>
XML;

$xml = new SimpleXMLIterator($note);

// rewind to the first element
$xml->rewind();

// return current element
var_dump($xml->current());
?>
Run Example »

Definition and Usage

The current() function returns the current element.


Syntax

SimpleXMLIterator::current()

Technical Details

Return Value: The current element (as a SimpleXMLIterator object) on success. NULL on failure
PHP Version: 5.0+

❮ PHP SimpleXML Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.