3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Recursion { private static function printArray($a) { print_r($a); } public static function recursionInitiatorParent($information, $list) { self::$array = $information; self::$keylist = $list; $keywords = explode(",", self::$keylist); echo "Before: \n\n"; self::printArray(self::$array); foreach($keywords as $key) self::recursionInitiator(self::$array, $key); echo "\n======================================= \n\n"; self::printArray(self::$array); } private static function recursionInitiator($a, $key) { foreach($a as $record) { if(is_array($record)) { // foreach($record as $key_internal=>$value_internal) // if($key_internal == $key) // $value_internal = self::$asterisk; echo "\n"; printArray($record); } else { //self::recursionInitiator($record, $key); echo "\n" . $record; } } } private static $asterisk = "**"; private static $array; private static $keylist; } $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 = "telephone,iin"; Recursion::recursionInitiatorParent($information, $list);
based on 5dhLg
Output for 7.0.0 - 7.2.0
Before: 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 ) someUsername somePassword card_1234 pin_356 iin_123 Fatal error: Uncaught Error: Call to undefined function printArray() in /in/guU3Y:36 Stack trace: #0 /in/guU3Y(20): Recursion::recursionInitiator(Array, 'telephone') #1 /in/guU3Y(61): Recursion::recursionInitiatorParent(Array, 'telephone,iin') #2 {main} thrown in /in/guU3Y on line 36
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Before: 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 ) someUsername somePassword card_1234 pin_356 iin_123 Fatal error: Call to undefined function printArray() in /in/guU3Y on line 36
Process exited with code 255.