how can i access the elements of array which is located in a value of associative array in php -


i have array holds data returned sql query

$user = $stmt->fetch(pdo::fetch_assoc); $user["username"] = "username1"; $user["password"] = "password1"; 

i have associative array $user array saved value of key:

return array("invalid credentials:"=>"false", "credentials"=>$user); 

my question how can access values($user) of "credentials" key have tried $user["credentials"] => "username"; not work

you can access value of multidimentional array stacking keys in brackets;

so if function returned array you've created $arr

$arr = somefunction(); // whatever function you're calling named $username = $arr['credentials']['username']; 

hope helps.


Comments

Popular posts from this blog

java - unable show chart in xls document using jasper reports -

javascript - How to change image src on success AJAX -

java.lang.RuntimeException: Could not generate dummy secret at sun.security.ssl.RSAClientKeyExchange.<init> -