CodeIgniter Forums
Access variable from a helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Access variable from a helper (/thread-45519.html)



Access variable from a helper - El Forum - 09-24-2011

[eluser]Unknown[/eluser]
I have a state list array that I would like to drop in a helper.
This is pretty much just static data and should not need to be put in a function for what I want to do with it.

How do I access the helper variable?

Helper File:

$state_list = array('AL'=>"Alabama",
'AK'=>"Alaska");


Controller:

$this->load->helper('state_helper'); // File name State_helper.php in helpers folder verified it gets called.

Read Var in controller:

echo ('-- '.$this->state_helper->state_list['AL']); // NO

echo ('-- '.$this->state_list['AL']); // NO

echo ('-- '.$state_list['AL']); // NO