I have an array
$user = array(
"name" => "John Doe",
"age" => "26",
"country" => "US",
"city" => "LA"
);
I want to access the variable's key "age" in a function. I'm currently using this:
global $user;
return $user['age'];
But I wonder if this is more efficient:
$age = $GLOBALS['user']['age'];
return $age;
Which one is best if you want to globally access only specific indexes/keys of an array variable?