I have a class that has this method:
public function user_status()
{
$json = //some code here...
$result = json_decode($json, true);
$status = array(
'key1' => $val1,
'key2' => $val2
);
return $status;
}
when calling like this:
$user = new Class();
echo $user->user_status();
it just returns the word Array
but when dumping like so:
echo "<pre>User: ", print_r($user->user_status(), TRUE), "</pre>";
it prints the array as expected:
User: Array
(
[key1] => val1
[key2] => val2
)
I want to output the array values so I tried calling it like below but its giving me a parse error.
echo $user->user_status()->['key2'];
Whats the proper syntax to output the array values?