3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Recursion { private static function printArray() { print_r(self::$array); } public static function recursionInitiatorParent($information, $list) { self::$array = $information; self::$keylist = $list; $keywords = explode(",", self::$keylist); echo "Before: \n\n"; self::printArray(); foreach($keywords as $key) self::recursionInitiator(self::$array, $key); echo "\n======================================= \n\n"; self::printArray(); } private static function recursionInitiator($array, $key) { if(count($array) < 1) return; foreach($array as $record) { if(is_array($record)) { foreach($record as $key_internal=>$value_internal) if($key_internal === $key) $value_internal = self::$asterisk; } else self::recursionInitiator($record, $key); } } 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);
Output for git.master, git.master_jit, rfc.property-hooks
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 ) Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/KWtXY:28 Stack trace: #0 /in/KWtXY(41): Recursion::recursionInitiator('someUsername', 'telephone') #1 /in/KWtXY(20): Recursion::recursionInitiator(Array, 'telephone') #2 /in/KWtXY(59): Recursion::recursionInitiatorParent(Array, 'telephone,iin') #3 {main} thrown in /in/KWtXY on line 28
Process exited with code 255.

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:
56.6 ms | 402 KiB | 8 Q