I have a problem when I using the method find in models.
if I have a table called user like this :
id name
1 linbob
2 phalcon
3 framework
My code:
$userData = User::find();
foreach($userData as $key => $data) {
echo 'key is '.$key.' and user is '.$data->name.'<br />';
}
the output is :
linbob
phalcon
framework
but if I have the code :
$userData = User::find();
echo $userData[-1]->name;
echo $userData[-100]->name;
why the output is the first value and why this key has value?