3v4l.org

run code in 300+ PHP versions simultaneously
<?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);
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
=============== Warning: Undefined variable $information in /in/ZrQTB on line 14 Fatal error: Uncaught TypeError: ArrayIterator::__construct(): Argument #1 ($array) must be of type array, null given 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.18 - 7.0.33, 7.1.4 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
=============== 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.3.32 - 7.3.33
=============== 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.17, 7.1.0 - 7.1.3
=============== 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.5.0 - 5.5.38, 5.6.0 - 5.6.40
=============== 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.

preferences:
227.96 ms | 402 KiB | 330 Q