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

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -