3v4l.org

run code in 300+ PHP versions simultaneously
<?php $information = array("login" => "someUsername", "password" => "somePassword", "card_pin"=>"card_1234", "pin"=>"pin_356", "iin" => "iin_123", "shipping" => array("telephone" => array("value" => "telephone_998")), "cardnumber" => "card_number_876", "customer_id" => "customer_654", "telephone" => "someOtherTelephoneNumber555"); print_r($information); echo "\n\n"; $key_parent = "telephone"; $iterator = new RecursiveIteratorIterator( new RecursiveArrayIterator($information), RecursiveIteratorIterator::SELF_FIRST); foreach ($iterator as $key => $val) { if($key == $key_parent) { $information[$key] = "**"; } else { if(is_array($val)) { //echo "$key:\n"; foreach($val as $k => $v) { if($k == $key_parent) $val[$k] = "**"; } } // else { // echo "$key => $val\n"; // } } } print_r($information);
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Array ( [login] => someUsername [password] => somePassword [card_pin] => card_1234 [pin] => pin_356 [iin] => iin_123 [shipping] => Array ( [telephone] => Array ( [value] => telephone_998 ) ) [cardnumber] => card_number_876 [customer_id] => customer_654 [telephone] => someOtherTelephoneNumber555 ) Array ( [login] => someUsername [password] => somePassword [card_pin] => card_1234 [pin] => pin_356 [iin] => iin_123 [shipping] => Array ( [telephone] => Array ( [value] => telephone_998 ) ) [cardnumber] => card_number_876 [customer_id] => customer_654 [telephone] => ** )

preferences:
158.34 ms | 405 KiB | 183 Q