3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* function loop($array) { echo '<ol class="dd-list">'; $arrayObj = new ArrayObject($array); foreach ( $iterator = $arrayObj->getIterator() as $key => $value ) { if(is_array($value)) { loop($iterator->current()); } else { if($iterator->key()=='position') { echo '<li class="dd-item" data-id="' . $iterator->current() . '">'; echo '<div class="dd-handle">' . $iterator->key() . ' ' . $iterator->current() . '</div>'; echo '</li>'; } } } echo '</ol>'; } */ $testArray = array('1', '2', array('3', '4')); $arrayObj = new ArrayObject($array); foreach ( $iterator = $arrayObj->getIterator() as $key => $value ) { echo 'key ' . $iterator->key(); echo "\n"; echo 'current' . $iterator->current(); echo "\n"; echo "\n"; } //loop($testArray);
Output for 7.0.20, 7.1.5 - 7.3.0rc4
Notice: Undefined variable: array in /in/L411Z on line 21 Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object in /in/L411Z:21 Stack trace: #0 /in/L411Z(21): ArrayObject->__construct(NULL) #1 {main} thrown in /in/L411Z on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.14, 7.1.0
Notice: Undefined variable: array in /in/L411Z on line 21 Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object, using empty array instead in /in/L411Z:21 Stack trace: #0 /in/L411Z(21): ArrayObject->__construct(NULL) #1 {main} thrown in /in/L411Z on line 21
Process exited with code 255.
Output for 5.1.1 - 5.6.28
Notice: Undefined variable: array in /in/L411Z on line 21 Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Passed variable is not an array or object, using empty array instead' in /in/L411Z:21 Stack trace: #0 /in/L411Z(21): ArrayObject->__construct(NULL) #1 {main} thrown in /in/L411Z on line 21
Process exited with code 255.
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/L411Z on line 30
Process exited with code 255.
Output for 5.0.4 - 5.0.5
Notice: Undefined variable: array in /in/L411Z on line 21 Fatal error: Uncaught exception 'Exception' with message 'Passed variable is not an array or object, using empty array instead' in /in/L411Z:21 Stack trace: #0 /in/L411Z(21): ArrayObject->__construct(NULL) #1 {main} thrown in /in/L411Z on line 21
Process exited with code 255.
Output for 5.0.0 - 5.0.3
Notice: Undefined variable: array in /in/L411Z on line 21 Warning: ArrayObject::__construct(): Passed variable is not an array or object, using empty array instead in /in/L411Z on line 21
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/L411Z on line 21
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: arrayobject in /in/L411Z on line 21