<?php
function test_print($item, $key)
{
echo "$key holds $item\n";
}
function recursion($array, $key_parent)
{
if(count($array) == 0)
return;
foreach (new RecursiveIteratorIterator(
new RecursiveArrayIterator($array),
RecursiveIteratorIterator::CATCH_GET_CHILD)
as $key => $value)
{
if(is_array($value))
{
echo 'My Array Node ' . $key;
recursion($value);
}
else
{
//echo 'My node ' . $key . ' with value ' . $value . PHP_EOL;
if($key == $key_parent)
$array[$key] = "**";
}
}
}
$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";
print_r($information);
//array_walk_recursive($information, 'test_print');
recursion($information, "login");
print_r($information);
preferences:
55.85 ms | 402 KiB | 5 Q