I want to fetch array from helper to controller but it's not working for me. This is my code.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function tamplate_function()
{
$navigaton_site=array("Header","Sidebar","Body","Footer");
return $navigaton_site;
}
$this->load->helper('tamplate_helper' );
$data['tamplate_array'] = $this->tamplate_function();
var_dump($data);
Dont use $this keyword. try-
$this->load->helper('tamplate_helper' );
$data['tamplate_array'] = tamplate_function();
Try this code, it works for me:
$this->load->helper('template'); //You don't need the _helper string, just the name
$var = template_function();
var_dump($var); // or try print_r($var);
Try to modify your helper:
if ( ! function_exists('tamplate_function') )
{
function tamplate_function()
{
$navigaton_site=array("Header","Sidebar","Body","Footer");
return $navigaton_site;
}
}
If this do not work try to get the instance with:
$ci = get_instance();
$ci->load->helper('template');