So I've got an object containing several rows from a database (using PHP).
How should I organize them into an array to pass through JSON?
For example, say I want to list some users. I've already done the correct query, and have an object called $u
foreach($u as $user)
{
$rows['name'] = $user->firstname . $user->lastname;
}
Now I'm new to JSON, and I'm trying to think of the easiest way to access the rows later. For this example I'd need to be able to access "name", "registered", and "id". How should I build up the array before I use json_encode();
?