Newbie array 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: Newbie array question (/showthread.php?tid=26738) |
Newbie array question - El Forum - 01-21-2010 [eluser]brixxster[/eluser] Hello everyone, I have an array Code: $data['rows'] ( 'fname' => My Name, 'lname' => My Last name, 'acct_type' => 2) I wanted to test acct_type so I can redirect to specific function according to its value. I'm using switch case for the testing, what is the correct syntax for getting the acct_type value in the array? I'm still a newbie so forgive me if this reads like a dumb question. thanks everybody. Newbie array question - El Forum - 01-21-2010 [eluser]JHackamack[/eluser] Depending on the array type (object or regular) it would either be Code: //regular or Code: //object If you are using active record to set the $data['rows'] array then it is probably object, but if you are setting it yourself then its probably regular. Newbie array question - El Forum - 01-21-2010 [eluser]brixxster[/eluser] Thanks for the quick reply jhackamack but unfortunately I still got errors. Here's the snippet of the code I have in the controller... Code: $this->load->model('model_membervalidation'); I don't know what I'm doing wrong here... Newbie array question - El Forum - 01-21-2010 [eluser]JHackamack[/eluser] can you paste in the results from Code: echo "<pre>"; Newbie array question - El Forum - 01-21-2010 [eluser]brixxster[/eluser] here's the result... Code: Array Newbie array question - El Forum - 01-21-2010 [eluser]JHackamack[/eluser] Ah, i see the problem, you have an array under an array. Code: echo $data['rows'][0]->acct_type; Try that. Newbie array question - El Forum - 01-21-2010 [eluser]brixxster[/eluser] That worked! Thanks a lot jhackamack :wow: |