I have an array full of credentials following this pattern:
Array (
[0] : Array (
"login" => "toto"
"passwd" => "mdpsecrethashe"
)
[1] : Array (
"login" => "titi"
"passwd" => "supermdp"
)
[2] : Array (
[...]
)
[...]
)
I want to get the desired credentials thanks to the login and change the password. Here is my attempt:
function getListWithModifiedPassword($credentials_list, $wanted_login, $new_password){
echo(print_r($credentials_list, TRUE));
foreach ($credentials_list as $credentials)
if ($credentials['login'] === $wanted_login)
$credentials['passwd'] = hash('whirlpool', $new_password);
echo(print_r($credentials_list, TRUE));
return $credentials_list;
}
Assignation on line 5 doesn't want to work whatever the value (no change between the two echo(print_r($credentials_list, TRUE));
, even though the condition on line 4 is true (tested: if I replace line 5 with echo "Hello world\n";
it works).
What is happenning in here ?