![]() |
foreach on objects noob question - 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: foreach on objects noob question (/showthread.php?tid=18432) |
foreach on objects noob question - El Forum - 05-06-2009 [eluser]september28[/eluser] Hi there, Another noob question from me - I am having complete mind freeze as to how to loop an object.. here is my dilemma: Code: $this->db->select('links.ex1, links.ex2'); basically the $row->links variable is from a previous db query result now i want to create an object with multiple $slugs the way i have it at the minute with $row->links[] = $slug means that the slug is nicely added to an array however i wasnted to keep consistent and have this as an object and then loop through the object in my view... is there a way i can do the equivalent of [] with an object?? Cheers, Dan foreach on objects noob question - El Forum - 05-06-2009 [eluser]TheFuzzy0ne[/eluser] No. That's what arrays are for. ![]() Everything in an object requires a name, so you'd have to assign like this@ Code: $obj->some_var = TRUE; |