Welcome Guest, Not a member yet? Register   Sign In
access a config variable inside helper function
#1

[eluser]ranjitbd[/eluser]
Code:
// meal is an array declared in a config file
$config['meal'] = array (
                          '1' => 'Breakfast',
                          '2' => 'Lunch',
                          '3' => 'Dinner',
                        );    
//this is a function inside a helper file
    function meal_list($list)
    {
        $meal = $this->config->item('meal');
        $meal_arr = split(",", $list);
        $return_arr = "";
        foreach($meal_arr as $i)
        {
          $return_arr = $return_arr." ".$meal[$i];
        }
        return $return_arr;
    }

// but when executing it showing errors
// Fatal error: Using $this when not in object context in
// C:\xampp\htdocs\travelmartbd\system\helpers\common_function_helper.php on line 37
// so how to access a config variable inside helper function


Messages In This Thread
access a config variable inside helper function - by El Forum - 11-10-2009, 03:34 AM
access a config variable inside helper function - by El Forum - 11-10-2009, 04:57 AM



Theme © iAndrew 2016 - Forum software by © MyBB