I iterate through a multidimensional array with RecursiveIteratorIterator and would like to be able to know if the current element is the last child of it's depth. I thought about this:
$iterator = new RecursiveIteratorIterator($array,
RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $val) {
$next = clone $iterator;
$next->next();
$lastChild = ($next->getDepth() < $iterator->getDepth());
}
But the RecursiveIteratorIterator says it's not cloneable.