3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function test_print($item, $key) { echo "$key holds $item\n"; } function recursion($array) { echo "==============="; if(count($array) == 0) return; foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($information), RecursiveIteratorIterator::CATCH_GET_CHILD) as $key => $value) { if(is_array($value)) recursion($value); else echo 'My node ' . $key . ' with value ' . $value . PHP_EOL; } } $information = array("login" => "someUsername", "password" => "somePassword", "card_pin"=>"card_1234", "pin"=>"pin_356", "iin" => "iin_123", "shipping" => array("telephone" => "telephone_998"), "cardnumber" => "card_number_876", "customer_id" => "customer_654"); $list = "login,customer_id"; //array_walk_recursive($information, 'test_print'); recursion($information);
based on 6Oflg
Output for 7.0.20, 7.1.5 - 7.2.0
=============== Notice: Undefined variable: information in /in/ZrQTB on line 14 Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object in /in/ZrQTB:14 Stack trace: #0 /in/ZrQTB(14): ArrayIterator->__construct(NULL) #1 /in/ZrQTB(34): recursion(Array) #2 {main} thrown in /in/ZrQTB on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.6, 7.1.0
=============== Notice: Undefined variable: information in /in/ZrQTB on line 14 Fatal error: Uncaught InvalidArgumentException: Passed variable is not an array or object, using empty array instead in /in/ZrQTB:14 Stack trace: #0 /in/ZrQTB(14): ArrayIterator->__construct(NULL) #1 /in/ZrQTB(34): recursion(Array) #2 {main} thrown in /in/ZrQTB on line 14
Process exited with code 255.
Output for 5.3.19 - 5.6.28
=============== Notice: Undefined variable: information in /in/ZrQTB on line 14 Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Passed variable is not an array or object, using empty array instead' in /in/ZrQTB:14 Stack trace: #0 /in/ZrQTB(14): ArrayIterator->__construct(NULL) #1 /in/ZrQTB(34): recursion(Array) #2 {main} thrown in /in/ZrQTB on line 14
Process exited with code 255.