3

Just for some background I am using codeigniter with the template sparks.

So in my controller i have the following function

public function information()
{     
$this->load->library('session');
$developer_id = $this->session->userdata('developer_id');
$this->load->model("Developer_model");
$information = $this->Developer_model->get_developer($developer_id);
$this->template->set('information', (array) $information); 
$this->template->build('dashboard/information'); 
}

In my view i am echoing out like so

<?php echo $information['email']; ?>

For some reason i am getting back "Message: Undefined index: email"

This my first question so hopefully i am not to unclear, but essentially i am getting $information from my database and trying to echo out the email which is just one thing in an array of items.

When i var_dump $information i get the following:

object(stdClass)#21 (2) { ["timestamp"]=> int(1353444880991) ["result"]=> object(stdClass)#22 (3) { ["email"]=> string(21) "[email protected]" ["api_key"]=> string(64) "de0f57acfc018882841b3255e89da11cb238160e84a66fe5b45bda8c51137c72" } } 

Thanks in advance for the help, only been working with codeigniter for 2 months prior to that i have literally done no coding besides some really minor html nonsense., so go easy on me =D

1
  • Welcome to StackOverflow. That's a good first question, thanks for posting. Commented Nov 20, 2012 at 21:18

2 Answers 2

5

If you look at your vardump, there is a second class "result" inside of your information class. Try $information["result"]["email"];

Sign up to request clarification or add additional context in comments.

Comments

3

In your model return response->result; instead of response. And then you can use ... $information['email']; ...should work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.