3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectKeyIterator extends IteratorIterator { public function __construct(\Traversable $iterator) { parent::__construct($iterator); } public function key() { $key = parent::key(); return (object)array('key' => $key); } } /*foreach(new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))) as $key => $value) { var_dump($key, $value); }*/ $iterator = new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))); $iterator->rewind(); while ($iterator->valid()) { $key = $iterator->key(); if(is_int($key) || is_string($key)) { $array[$key] = $iterator->current(); } else { $array[] = $iterator->current(); } $iterator->next(); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ObjectKeyIterator::key() should either be compatible with IteratorIterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/Ir0KA on line 9

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.54 ms | 401 KiB | 8 Q