If I have reached this problem, you ask how to work with many objects?
So, if you use an array of objects, for example, from ORM.
$users_list = new Users(); $arr_users = $users_list->all();
In $ arr_users you will have an array with many user objects from your database. Each object has some properties, for example: id, name, gender and age.
foreach($arr_users as $single_user) { echo $single_user->id; echo $single_user->name; echo $single_user->gender; echo $single_user->age; }
If you need only one user:
echo $arr_users[1]->name;
You can also work with an array of such objects. First, created a new array from $ arr_users;
foreach($arr_users as $single_user){ $arr_user_by_id[$single_user->id] = $single_user; }
Now you have a new array, where the keys are the user ID and the user of the value object.
Thus, you can get information about the user by his identifier.
echo $arr_users[$_GET['uid']]->name;
Hope I could help to understand a little.
tiomat
source share