GoLang RecursiveArrayIterator::getChildren

request it (264)
GoLang replacement for PHP's RecursiveArrayIterator::getChildren [edit | history]

Do you know a GoLang replacement for PHP's RecursiveArrayIterator::getChildren? Write it!

PHP RecursiveArrayIterator::getChildren

PHP original manual for RecursiveArrayIterator::getChildren [ show | php.net ]


(PHP 5 >= 5.1.0, PHP 7)

RecursiveArrayIterator::getChildrenReturns an iterator for the current entry if it is an array or an object


public RecursiveArrayIterator RecursiveArrayIterator::getChildren ( void )

Returns an iterator for the current iterator entry.


This function has no parameters.

Return Values

An iterator for the current entry, if it is an array or object.


An InvalidArgumentException will be thrown if the current entry does not contain an array or an object.


Example #1 RecursiveArrayIterator::getChildren() example

= array("a" => "lemon""b" => "orange", array("a" => "apple""p" => "pear"));

$iterator = new RecursiveArrayIterator($fruits);

while (
$iterator->valid()) {

    if (
$iterator->hasChildren()) {
// print all children
foreach ($iterator->getChildren() as $key => $value) {
$key ' : ' $value "\n";
    } else {
"No children.\n";


The above example will output:

No children.
No children.
a : apple
p : pear

See Also