views:

30

answers:

2

I have a sequence of number like follows

1 -> 25, 2 -> 60, 3 -> 80, 4 -> 100 and so on

which means that if input is 1 output will be 25 and so on...I need to store it in global array.I would like to use it in multiple pages also.In codeigniter where i can declare a global array and store all these?

I am trying like as follows in constants.php

$CONFIDENCEVALUE = array(); $CONFIDENCEVALUE[] = array('1'=>25,'2'=>'60','3'=>80,'4'=>100);

If it is correct how can access these array value in required pages.Help me please.I am not an expert with codeignitor.Thanks

+2  A: 

If I were you i'd look at adding a custom config file (see http://codeigniter.com/user_guide/libraries/config.html).

So in eg. application/config/confidencevalue.php add the following

$CONFIDENCEVALUE = array('1'=>25,'2'=>'60','3'=>80,'4'=>100);
$config['confidencevalue'] = $CONFIDENCEVALUE;

Add the config file to your application/config/autoload.php and you'll then be able to access your array through the config class using $this->config->item('1', 'confidencevalue'); (replacing the 1 for the value you're looking for).

WeeJames
A: 

Store the array in a session variable:

$this->session->set_userdata('cvarray', $CONFIDENCEVALUE);

To access the array later:

$this->session->userdata('cvarray');

CodeIgniter Session Class

coolgeek