@ 2015-11-06T13:27:50Z <?php
class Recursion
{
public static function recursion($information, $keylist)
{
$global_array = array();
$keys = explode($keylist, ",");
foreach($keys as $individual_key)
$global_array = self::recursionLevelTwo($information, $individual_key);
return $global_array;
}
private static function recursionLevelTwo($array, $key)
{
if(count($array) == 0)
return;
$global_array = array();
foreach($array as $k => $v)
{
if($k == $key)
if($array[$k] != self::$asterisk)
$array[$k] = self::$asterisk;
else
{
if(is_array($v))
{
$temp_array = self::recursionLevelTwo($v, $key);
array_push($global_array, $temp_array);
}
}
}
return $global_array;
}
private static $asterisk = "**";
}
$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",
"telephone" => "someOtherTelephoneNumber555");
$list = "login,customer_id";
print_r($information);
echo PHP.EOL;
echo PHP.EOL;
$global_array = Recursion::recursion($information, $list);
print_r($global_array);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.6.15 0.013 0.037 18.16 5.6.14 0.013 0.040 18.18 5.6.13 0.000 0.047 18.21 5.6.12 0.010 0.047 21.00 5.6.11 0.007 0.050 20.90 5.6.10 0.010 0.077 21.11 5.6.9 0.027 0.043 20.97 5.6.8 0.017 0.070 20.45 5.5.30 0.000 0.040 18.01 5.5.29 0.007 0.037 17.98 5.5.28 0.010 0.073 20.80 5.5.27 0.013 0.060 20.88 5.5.26 0.013 0.073 20.98 5.5.25 0.010 0.050 20.59 5.5.24 0.020 0.073 20.16
preferences:dark mode live preview
23.45 ms | 401 KiB | 5 Q