Well I could not find a better title for my case, I have the following function :
public function select_tokens() {
$sql = "SELECT * FROM 'users'";
$select_tokens = Database::DB()->prepare($sql);
$select_tokens->execute();
$fetch = $select_tokens->fetchAll(PDO::FETCH_ASSOC);
foreach ($fetch as $token) {
$tokens[] = [
'user_token' => $token['user_token'],
'user_token2' => $token['user_token2']
];
}
return $tokens;
}
Note, I am returning $tokens
which in the case I could use like this:
$tk = $users->select_tokens();
And then get the index:
$tk['user_token'];
or
$tk['user_token2'];
But I do not know why this error returns me:
Notice: Undefined index: user_token
or
Notice: Undefined index: user_token2