CodeIgniter Forums
Access returned array directly - 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: Access returned array directly (/showthread.php?tid=29408)



Access returned array directly - El Forum - 04-08-2010

[eluser]evolutionxbox[/eluser]
I am using the calendar class and its function 'adjust_date()'.

It returns an array depending on what I put in:
Code:
Array ( [month] => 04 [year] => 2010 ) 1

This is how I get to it so far:
Code:
$date = $this->calendar->adjust_date($month, $year);
$adjusted_month = $date['month'];

How can I access the return array straight off the bat? I was thinking of something like this:
Code:
$date = $this->calendar->adjust_date($month, $year)->['month'];

This doesn't work... any ideas?


Access returned array directly - El Forum - 04-09-2010

[eluser]adamp1[/eluser]
Edit:
I think you will have to use the temp variable. Someone asked the same question here http://stackoverflow.com/questions/13109/php-access-array-value-on-the-fly


Access returned array directly - El Forum - 04-09-2010

[eluser]evolutionxbox[/eluser]
Ah well, one more line of code won't hurt.