JSON & PHP - Building up the rows correctly

knifepanofete

New Member
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 \[code\]$u\[/code\]\[code\]foreach($u as $user) { $rows['name'] = $user->firstname . $user->lastname; }\[/code\]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 \[code\]json_encode();\[/code\]?
 
Back
Top