- print_r: documentation ( source)
<?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);