Array in my code is quite big so I pasting it in pastebin. http://pastebin.com/6tviT2Xj
I don't understand why I am getting endless loop
Logic of this script is:
$it = new ArrayIterator($options);
while($it->valid()) {
print $it->key();
print $it->current();
}
Because you never move in you iterator (with ArrayIterator::next()).
while ($it->valid()) {
...
$it->next();
}