Get value from object - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Get value from object (/showthread.php?tid=48167) |
Get value from object - El Forum - 01-06-2012 [eluser]Perkin5[/eluser] Probably a very old chestnut but I can't find an answer by searching the forum. I have an object $record derived from a db. When I run print_r($record) I get: Code: stdClass Object ( [id] => 4 [qty] => 0 [price] => 3.00 [name] => default [filename] => MH0005.jpg [cat] => agriculture [description] => nil) so the model is working OK. But now, within a controller method, how can I grab the value of any one of the elements? I've tried each of these: Code: $id = $record['id']; but it throws an error every time. |